How do I yank or delete a line range directly into a named register without selecting it visually?
Vim's :[range]yank and :[range]delete Ex commands let you capture arbitrary line ranges into a register from the command line, bypassing the need to move the cu
category:
registers
tags:
#registers
#ex-commands
#editing
#normal-mode
How do I collapse multiple consecutive spaces into a single space throughout a file?
The pattern \s\+ matches one or more whitespace characters (spaces, tabs).
category:
editing
tags:
#editing
#search
#ex-commands
How do I use a Vimscript expression to compute the replacement text in a substitution?
Prefixing the replacement field of :s with \= makes Vim evaluate the rest as a Vimscript expression and use the result as the replacement string.
category:
command-line
tags:
#search
#ex-commands
#editing
#command-line
How do I prepend a value to the beginning of a comma-separated Vim option like path or wildignore?
Vim's :set option^=value operator prepends a value to the front of a list-style option, giving it the highest priority.
category:
config
tags:
#config
#ex-commands
#settings
#advanced
How do I open a floating window showing diagnostic details at the cursor using a built-in Neovim key?
Neovim 0.
category:
buffers-windows
tags:
#diagnostics
#lsp
#floating-window
#neovim
#buffers
#windows
How do I load a set of files matching a glob pattern into Vim's argument list for bulk editing?
Vim's argument list (arglist) is a named list of files that you can operate on as a group.
category:
command-line
tags:
#ex-commands
#command-line
#editing
How do I evaluate a Vimscript expression and insert the result into a command-line command?
<C-r>= (command-line mode)
Just like = lets you insert evaluated expressions in insert mode, you can use it inside an Ex command on the command line to embed any Vimscript expression resu
category:
command-line
tags:
#registers
#ex-commands
#command-line
How do I quickly re-insert the text I just typed without leaving insert mode?
While in insert mode, pressing re-inserts whatever text you typed during your previous insert session.
category:
editing
tags:
#insert-mode
#editing
#registers
#repeat
How do I search for a pattern only within a visual selection?
The \%V pattern atom restricts a search to the region spanned by the last visual selection.
category:
search
tags:
#search
#visual-mode
#patterns
#normal-mode
How do I run a command on every line matching a pattern?
The :g/pattern/command (global) command executes an Ex command on every line in the file that matches the given pattern.
category:
command-line
tags:
#ex-commands
#search
#editing
#command-line
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 replace a line (or range) with the output of a shell command in Vim?
:.
category:
command-line
tags:
#ex-commands
#editing
#command-line
How do I append text at the end of multiple lines using visual block?
Combining visual block mode with $ and A lets you append text at the end of multiple lines, even when the lines have different lengths.
category:
visual-mode
tags:
#visual-mode
#insert-mode
#editing
How do I zero-pad every number in a line using a Vim substitute expression?
:s/\v\d+/\=printf('%04d', submatch(0))/g
Substitution expressions let Vim compute each replacement dynamically, which is ideal when plain capture groups are too limited.
category:
editing
tags:
#editing
#substitution
#regex
#vimscript
How do I open a file found in Vim's path setting in a new split without typing the full path?
:sfind (split-find) searches Vim's path setting for a file matching the given name and opens it in a new horizontal split, all in one command.
category:
navigation
tags:
#navigation
#buffers
#windows
#ex-commands
How do I resize a split window by an exact number of columns or rows using a count in Vim?
All four window resize mappings accept an optional count prefix that multiplies the resize amount.
category:
buffers-windows
tags:
#windows
#buffers-windows
#normal-mode
How do I create an incrementing number sequence from identical numbers in Vim?
When you have multiple lines with the same number and want to turn them into a sequence (1, 2, 3.
category:
editing
tags:
#editing
#visual-mode
#normal-mode
How do I execute a recorded macro a specific number of times?
Prefix the @ macro-execution command with a count to run the macro that many times in a row.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I record a macro directly into the system clipboard register?
You can record macros into any register, including the system clipboard (+).
category:
registers
tags:
#registers
#macros
#clipboard
#recording
How do I insert all completion matches at once on the command line instead of cycling through them one by one?
<C-a> (command-line mode)
In command-line mode, inserts all completions for the word before the cursor at once, as a space-separated list.
category:
command-line
tags:
#command-line
#ex-commands