How do I write a Vim regex that matches across multiple lines?
\_.\+
By default, .
\_.\+
By default, .
:set equalprg=gofmt
By default, Vim's = operator re-indents text using its internal rules.
config #config #editing #ex-commands #formatting #indentation
:s/\v\w+/\U&/g
Vim's substitute command supports special case-conversion sequences in the replacement string, letting you transform matched text to upper or lower case without
!{motion}{cmd}<CR>
In normal mode, !{motion} sends the lines covered by the motion to a shell command's stdin and replaces them with stdout.
qq{actions}@qq
A recursive macro ends by calling itself, so it loops automatically without you pressing @q repeatedly.
gcip
The vim-commentary plugin exposes gc as a comment operator, which means it composes with any Vim motion or text object.
plugins #plugins #editing #commenting #text-objects #normal-mode
yss"
The yss{char} mapping from the vim-surround plugin surrounds the entire current line (ignoring leading whitespace) with the chosen delimiter.
<C-r>-
In insert mode, - pastes the contents of the small delete register ("-).
:sort n
:sort n sorts lines by the first number found on each line, comparing values numerically rather than as strings.
:Subvert
The vim-abolish plugin's :Subvert command (abbreviated :S) substitutes a word across all its case variants simultaneously.
@q (inside macro recording)
A recursive macro calls itself as its last action, causing it to repeat indefinitely until it hits an error (like reaching end of file or failing a search).
<C-o> (insert mode)
Pressing while in insert mode lets you execute exactly one normal mode command and then automatically returns you to insert mode.
:w !diff % -
The command :w !diff % - pipes the current buffer's contents to an external diff command that compares it against the saved file on disk.
buffers-windows #buffers-windows #ex-commands #editing #navigation
{visual}p
When you visually select text and press p, Vim replaces the selection with the contents of the default register and saves the replaced text into the unnamed reg
:[range]norm @{register}
The :normal command executes normal-mode keystrokes on each line in a range — including macro playback.
:center, :right, :left
Vim includes three built-in Ex commands for text alignment that most users never discover: :center, :right, and :left.
<C-x><C-]>
Pressing in insert mode opens a completion menu populated from your project's tags file.
:%s/pattern/\=expr/g
Prefixing the replacement field of :s with \= tells Vim to evaluate the rest as a Vimscript expression and use its result as the replacement string.
O (in blockwise visual mode)
In blockwise Visual mode (), pressing O moves the cursor to the diagonally opposite corner of the rectangle.
C (visual-block)
In visual block mode, pressing C (uppercase) deletes from the leftmost column of the selection to the end of every selected line, then drops you into insert mod