How do I search and replace only whole word matches, not partial matches?
Wrapping your search pattern in \ word boundary anchors ensures that Vim only matches the exact whole word, preventing accidental replacements inside longer wor
category:
search
tags:
#search
#substitution
#regex
#ex-commands
#editing
How do I search and replace with confirmation for each match?
Adding the c flag to a substitute command makes Vim pause at every match and ask you whether to replace it.
category:
search
tags:
#search
#substitution
#ex-commands
#editing
How do I quickly surround a word with quotes, brackets, or parentheses?
Vim doesn't have a built-in "surround" operator, but you can wrap any word in quotes or brackets with a short sequence: ciw""P.
category:
editing
tags:
#editing
#text-objects
#normal-mode
#productivity
#surround
How do I swap a word with the contents of a register using visual mode?
The viwp command visually selects the word under the cursor and replaces it with the contents of the unnamed register (your last yank or delete).
category:
visual-mode
tags:
#editing
#visual-mode
#registers
#paste
#productivity
How do I toggle the case of an entire word in Vim?
The g~iw command toggles the case of every character in the word under the cursor — uppercase letters become lowercase and vice versa.
category:
editing
tags:
#editing
#text-objects
#case
#normal-mode
How do I revert a file to its state from a specific time ago?
:earlier {time} / :later {time}
Vim's :earlier and :later commands let you navigate the undo history by wall-clock time rather than by individual undo steps.
category:
editing
tags:
#editing
#undo-redo
#ex-commands
#advanced
#productivity
How do I navigate undo branches to recover changes that were overwritten by a new edit?
Vim doesn't have a simple linear undo stack — it maintains a full undo tree with branches.
category:
editing
tags:
#editing
#undo-redo
#normal-mode
#advanced
#productivity
How do I change the same column of text across multiple lines at once?
<C-v>jjc replacement<Esc>
Visual block mode's change command lets you replace a rectangular column of text across multiple lines in a single operation.
category:
visual-mode
tags:
#editing
#visual-mode
#block-mode
#normal-mode
#productivity
How do I expand or shrink a visual selection to the next text object boundary?
v + repeated iw/aw/i(/a(/ip/ap
Once you enter visual mode, you can progressively expand your selection by typing increasingly larger text objects.
category:
visual-mode
tags:
#visual-mode
#text-objects
#editing
#selection
#productivity
How do I select the text I just pasted or changed?
The ` [v] sequence visually selects the exact region of text that was last changed, pasted, or yanked into the buffer.
category:
visual-mode
tags:
#editing
#visual-mode
#marks
#paste
#productivity
How do I execute a single normal mode command without leaving insert mode?
Pressing in insert mode lets you execute one normal mode command and then automatically returns you to insert mode.
category:
editing
tags:
#editing
#insert-mode
#normal-mode
#productivity
How do I see spelling correction suggestions for a misspelled word?
When spell checking is enabled, the z= command opens a numbered list of spelling suggestions for the misspelled word under the cursor.
category:
editing
tags:
#editing
#spell-check
#normal-mode
#productivity
#prose
How do I create a macro that runs itself repeatedly until it fails?
A recursive macro calls itself at the end of its recording, creating a loop that repeats until a motion or command fails (like reaching the end of the file or f
category:
macros
tags:
#macros
#editing
#normal-mode
#automation
#advanced
How do I repeat the last f, t, F, or T character search on a line?
After using f, t, F, or T to jump to a character on the current line, pressing ; repeats the same search in the same direction, and , repeats it in the opposite
category:
navigation
tags:
#navigation
#motions
#normal-mode
#editing
#productivity
How do I overwrite existing text character by character without deleting first?
Replace mode lets you type over existing text one character at a time, like the "Insert" key behavior in traditional editors.
category:
editing
tags:
#editing
#normal-mode
#insert-mode
#replace
How do I reverse the order of all lines in a file?
The :g/^/m0 command is a clever use of Vim's global command to reverse every line in the file.
category:
command-line
tags:
#editing
#ex-commands
#global-command
#lines
How do I run a macro only on lines that match a specific pattern?
The :g (global) command combined with :normal @a lets you execute a recorded macro only on lines matching a pattern.
category:
macros
tags:
#macros
#ex-commands
#global-command
#editing
#automation
How do I set Vim options on a per-file basis without changing my vimrc?
A modeline is a special comment embedded in a file that Vim reads to apply file-specific settings automatically.
category:
config
tags:
#config
#editing
#modeline
#formatting
#productivity
How do I move the current line up or down without cutting and pasting?
The :m (move) command relocates lines to a new position in the file without using registers.
category:
editing
tags:
#editing
#ex-commands
#lines
#productivity
#mappings
How do I jump back to where I last made an edit?
The g; and g, commands let you navigate Vim's changelist — a per-buffer history of every position where you made a change.
category:
navigation
tags:
#navigation
#changelist
#editing
#normal-mode
#marks