How do I transform matched text to uppercase or lowercase directly inside a substitute replacement?
Vim's :substitute command supports case-transformation escape sequences in the replacement string.
category:
search
tags:
#search
#substitute
#ex-commands
#editing
#text-objects
How do I suppress the 'Pattern not found' error when a substitution has no match?
The e flag in Vim's :substitute command silently ignores the "E486: Pattern not found" error when the pattern does not match anything.
category:
search
tags:
#search
#substitute
#ex-commands
#macros
#editing
How do I re-insert the text from my last insert session and immediately return to normal mode?
Pressing (Ctrl + @, which is the NUL character) in insert mode inserts the same text that was typed during the most recent insert session, then immediately retu
category:
editing
tags:
#insert-mode
#editing
#undo-redo
How do I manually save the undo history for a file to a separate undo file in Vim?
The :wundo {file} command writes the current buffer's entire undo history to a file on disk.
category:
command-line
tags:
#undo-redo
#command-line
#editing
How do I autocomplete Vim command names and their arguments while in insert mode?
The key sequence in insert mode triggers Vim command-line completion — the same completion engine used at the : command prompt.
category:
editing
tags:
#insert-mode
#completion
#editing
#command-line
How do I center or right-align lines of text using Vim's built-in Ex commands?
Vim has three built-in Ex formatting commands — :left, :center, and :right — that align text within a specified column width.
category:
editing
tags:
#editing
#formatting
#ex-commands
#text
How do I wrap a word in a function call using vim-surround?
vim-surround's f and F surrounds let you wrap any text object inside a function call, prompting you for the function name.
category:
plugins
tags:
#plugins
#vim-surround
#editing
#text-objects
How do I edit a macro in-place using Vimscript without re-recording it?
:let @a = substitute(@a, "old", "new", "g")
When a recorded macro has a typo or wrong command buried inside it, you don't have to re-record the entire thing.
category:
macros
tags:
#macros
#registers
#vimscript
#editing
How do I run a command on lines matching a pattern within blocks matching another pattern?
The :global command accepts a range, which lets you scope its search to sections of the file rather than the entire buffer.
category:
command-line
tags:
#ex-commands
#search
#editing
#normal-mode
How do I paste the contents of a register as a new line below the cursor regardless of the register type in Vim?
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,
category:
editing
tags:
#registers
#editing
#paste
#ex-commands
#normal-mode
How do I switch to a faster regex engine in Vim when syntax highlighting is causing slowdowns?
Vim ships with two regex engines and lets you control which one is used.
category:
config
tags:
#config
#performance
#syntax
#regex
#editing
How do I append yanked text to an existing register without overwriting it in Vim?
Using an uppercase register letter with any operator appends to the register instead of replacing it.
category:
registers
tags:
#registers
#yank
#delete
#editing
#normal-mode
What is the difference between \n and \r in Vim substitution patterns and replacements?
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
category:
search
tags:
#search
#ex-commands
#editing
How do I navigate Vim's undo tree branches to access states that u and Ctrl-R can't reach?
Vim's undo history is a tree, not a linear stack.
category:
editing
tags:
#undo-redo
#normal-mode
#editing
How do I undo or redo all changes made within a specific time window in Vim?
: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.
category:
command-line
tags:
#undo-redo
#ex-commands
#editing
How do I highlight the entire column under the cursor to help with aligning data?
:set cursorcolumn (or the short form set cuc) highlights the entire vertical column where the cursor sits, painting a visible strip from top to bottom of the wi
category:
config
tags:
#config
#navigation
#editing
#normal-mode
How do I open or close a fold and all its nested folds at once?
zO and zC are the recursive counterparts to zo and zc.
category:
editing
tags:
#folding
#navigation
#editing
#normal-mode
How do I open or edit a file in the same directory as the file I am currently editing?
Vim expands % to the current file's path in Ex commands, and the :h modifier strips the last filename component to give you just the directory.
category:
command-line
tags:
#ex-commands
#buffers
#navigation
#editing
How do I capitalize the first letter of every word in a file using a substitute command?
Vim's substitute command supports case-conversion modifiers in the replacement string.
category:
search
tags:
#search
#ex-commands
#editing
#normal-mode
How do I edit an existing macro without re-recording it from scratch?
When a recorded macro contains a typo or needs a small tweak, you can modify it directly via the :let command rather than re-recording the entire sequence.
category:
macros
tags:
#macros
#registers
#editing
#normal-mode