How do I open the command-line window while in the middle of typing a command?
<C-f>
While typing in Vim's command line (after pressing :), pressing opens the command-line window with your current, unfinished command already filled in.
<C-f>
While typing in Vim's command line (after pressing :), pressing opens the command-line window with your current, unfinished command already filled in.
v:register
When writing custom mappings or operator functions, v:register gives you the register name that the user prefixed the mapping with.
:set formatprg={program}
Vim's gq operator normally reflows text to fit textwidth, but by setting formatprg you can delegate formatting to any external tool — a language formatter, a
matchlist()
matchlist({str}, {pattern}) runs a regex match and returns a list of all captured groups, making it the idiomatic way to extract structured data from strings in
:~
The :~ command repeats the last substitution but uses the current search pattern instead of the original pattern.
ZQ
ZQ is the discard-and-quit counterpart to ZZ.
:tabfind {name}
:tabfind is the tab-aware counterpart to :find.
<C-f> (in command line)
Pressing while you are already typing in the Vim command line (:), search line (/ or ?), or input prompt switches you into the command-line window with the curr
command-line #command-line #ex-commands #editing #normal-mode
:keepjumps {command}
The :keepjumps modifier lets you run any movement or command without recording a new entry in the jump list.
navigation #navigation #ex-commands #jump-list #normal-mode #vimscript
:s/pattern/\U&/g
Vim's :substitute command supports case-transformation escape sequences in the replacement string.
search #search #substitute #ex-commands #editing #text-objects
:s/pattern/replacement/e
The e flag in Vim's :substitute command silently ignores the "E486: Pattern not found" error when the pattern does not match anything.
:%center 80
Vim has three built-in Ex formatting commands — :left, :center, and :right — that align text within a specified column width.
:g/outer/,/end/g/inner/
The :global command accepts a range, which lets you scope its search to sections of the file rather than the entire buffer.
:put {reg}
The :put Ex command always inserts a register's content as a new line below the current line, regardless of whether the register holds characterwise, linewise,
editing #registers #editing #paste #ex-commands #normal-mode
<C-d> (in command mode)
Pressing in Vim's command line displays the full list of matching completions below the command prompt, without cycling through them one at a time.
command-line #command-line #completion #ex-commands #navigation
:set debug=msg
When troubleshooting mappings or scripts that use :silent!, errors disappear without a trace.
:wincmd {key}
:wincmd is the Ex command equivalent of any keystroke.
:s/\n/ /
One of the most confusing asymmetries in Vim's substitution syntax: \n and \r mean different things depending on whether they appear in the pattern or the repla
:earlier {N}m and :later {N}m
Vim's :earlier and :later commands let you travel through your edit history by wall-clock time rather than by individual undo steps.
:set gdefault
By default, :s/old/new/ only replaces the first occurrence of a pattern on each line.