How do I insert a blank line above or below the current line without entering insert mode?
Using :put ='' with an empty expression lets you insert blank lines in normal mode without ever entering insert mode.
category:
editing
tags:
#editing
#normal-mode
#ex-commands
#expression-register
#blank-line
How do I profile Vim startup time to find out which plugins are slowing it down?
vim --startuptime /tmp/vim-startup.log +qall && sort -k2 -rn /tmp/vim-startup.log | head -20
When Vim starts slowly, the --startuptime flag writes a timestamped log of every script and plugin loaded during initialization.
category:
config
tags:
#config
#performance
#startup
#profiling
#plugins
How do I add custom filetype detection for a new file extension without modifying Vim's built-in filetypes?
Vim automatically sources every file in ftdetect/ directories on the runtimepath when filetype detection runs.
category:
plugins
tags:
#config
#ex-commands
How do I define a custom Ex command that can accept a line range or count like built-in Vim commands?
:command -range {Name} ...
Custom Ex commands defined with :command -range can be called with a line range (e.
category:
command-line
tags:
#command-line
#ex-commands
#config
How do I change each occurrence of a search match one at a time, confirming each with the dot command?
The cgn + .
category:
search
tags:
#search
#editing
#normal-mode
#motions
How do I save multiple different views of the same file with independent fold and cursor states?
:mkview 2 and :loadview 2
Vim supports up to 9 numbered view slots per file.
category:
buffers-windows
tags:
#folding
#buffers-windows
#navigation
#config
How do I run a normal mode command on every visually selected line?
After making a visual selection, :'normal {command} runs any normal-mode command on each selected line individually.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#normal-mode
#editing
How do I encode and decode JSON data in Vimscript for configuration and plugin development?
Vim 8.
category:
config
tags:
#config
#vimscript
#ex-commands
How do I use glob() in Vimscript to get a list of files matching a wildcard pattern?
The glob() built-in function expands a wildcard pattern into a list of matching filesystem paths, entirely within Vimscript.
category:
config
tags:
#config
#vimscript
#files
#ex-commands
How do I create a mapping that calls a script-local function in Vim without namespace collisions?
(Script ID) is a Vimscript token that expands to a unique, per-script prefix at runtime.
category:
config
tags:
#config
#vimscript
#mappings
#functions
#normal-mode
How do I use POSIX character classes like [:alpha:] and [:digit:] in Vim search patterns?
Vim's regex engine supports POSIX character classes inside bracket expressions, giving you locale-aware, readable alternatives to manual character ranges like [
category:
search
tags:
#search
#regex
#patterns
#character-classes
How do I write a Vim search pattern that matches any character including newlines for multi-line searches?
The \ modifier in Vim extends any character class or atom to also match newlines.
category:
search
tags:
#search
#regex
#multiline
#patterns
How do I prevent a count prefix or visual range from corrupting an Ex command in a Vim mapping?
When writing nnoremap or vnoremap mappings that call Ex commands, Vim may silently prepend a count or a visual range (') to your command before it runs.
category:
config
tags:
#config
#ex-commands
#normal-mode
#visual-mode
How do I highlight a custom pattern with a priority so it wins over other overlapping highlights?
matchadd('Group', 'pattern', priority)
matchadd() accepts an optional third argument: a priority integer that controls which match wins when two patterns cover the same text.
category:
config
tags:
#config
#search
#normal-mode
How do I find the syntax highlighting group applied to the character under the cursor?
:echo synIDattr(synID(line('.'),col('.'),1),'name')
When customizing a colorscheme or debugging unexpected colors, you need to know exactly which highlight group is coloring the text under your cursor.
category:
config
tags:
#config
#search
#normal-mode
How do I complete keywords using only the current buffer as the source?
triggers keyword completion that searches only the current buffer for matches, scanning forward from the cursor.
category:
editing
tags:
#completion
#insert-mode
#editing
How do I insert all command-line completion matches at once without pressing Tab repeatedly?
Pressing on the command line expands all current completion matches into the command at once, rather than cycling through them one at a time with .
category:
command-line
tags:
#command-line
#completion
#ex-commands
How do I get the current Vim mode as a string for use in expression mappings or the statusline?
The mode() function returns a short string identifying the current editing mode — 'n' for Normal, 'i' for Insert, 'v' for Visual character-wise, 'V' for Visua
category:
macros
tags:
#macros
#normal-mode
#visual-mode
#insert-mode
#editing
How do I safely pass a Vim variable or the word under the cursor as an argument to a shell command?
The shellescape() function wraps a string in shell-safe quoting, escaping any special characters so it can be embedded in a shell command constructed with :exec
category:
command-line
tags:
#ex-commands
#command-line
#editing
#normal-mode
How do I prompt the user for input in the middle of a mapping or Vimscript function?
The built-in input() function pauses execution, displays a prompt at the bottom of the screen, and returns whatever the user types before pressing Enter.
category:
macros
tags:
#macros
#editing
#ex-commands
#insert-mode