How do I replace only the current match and then stop when doing an interactive substitution in Vim?
l (in :%s///gc confirm prompt)
When running an interactive substitution with the c flag (e.
category:
editing
tags:
#search
#editing
#substitution
#ex-commands
#normal-mode
How do I use gn as a text object to delete or yank the next search match?
The gn motion is a versatile text object that selects the next occurrence of the last search pattern.
category:
editing
tags:
#editing
#search
#text-objects
#normal-mode
#motions
How do I preview substitute changes inline while typing without opening a split?
When you are crafting a risky :substitute command, the expensive part is usually confidence, not typing.
category:
config
tags:
#config
#substitute
#search
#ex-commands
How do I create custom folds to collapse specific sections of code?
Vim supports several fold methods, but manual folding with zf gives you precise control over exactly which lines to collapse.
category:
editing
tags:
#folding
#normal-mode
#visual-mode
#editing
How do I search for and highlight text that exceeds a specific column width like 80 or 120?
The pattern /\%>80v.
category:
search
tags:
#search
#navigation
#normal-mode
How do I make keyword completion preserve the capitalization style I started typing?
The infercase option makes Vim's keyword completion smart about capitalization: it adapts each match to reflect the casing of the characters you've already type
category:
config
tags:
#completion
#insert-mode
#config
How do I search and replace text only on the current line?
The :s/old/new/g command replaces all occurrences of old with new on the current line only.
category:
search
tags:
#search
#ex-commands
#editing
How do I run a command on all open buffers at once?
:bufdo executes an Ex command in each open buffer in sequence, cycling through every buffer in the buffer list.
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
#batch
How do I read the contents of a Vim register into a variable or expression using Vimscript?
The getreg({name}) function returns the content of any register as a string.
category:
registers
tags:
#registers
#ex-commands
How do I search for the word under the cursor?
The command searches forward for the exact word under the cursor, jumping to the next occurrence.
category:
search
tags:
#search
#navigation
#normal-mode
How do I search for an exact multi-word phrase or special text I've selected?
In normal mode, searches for the word under the cursor with word-boundary anchors.
category:
search
tags:
#search
#visual-mode
#navigation
How do I split a complex Vim macro into reusable subroutines?
Record worker macro in @b, call it from @a with @b
Complex macros are hard to debug and maintain when crammed into a single register.
category:
macros
tags:
#macros
#registers
#editing
How do I run a recorded macro on every line in a range without using a count?
The :normal command executes normal-mode keystrokes on each line in a range — including macro playback.
category:
macros
tags:
#macros
#ex-commands
#normal-mode
#editing
How do I selectively replace occurrences one at a time, choosing to apply or skip each match?
The n.
category:
search
tags:
#search
#editing
#normal-mode
#dot-repeat
#motions
How do I run a macro on every line in a specific line number range?
The :normal command lets you execute Normal mode keystrokes over a range of lines.
category:
macros
tags:
#macros
#normal
#range
#ex-commands
How do I customize which patterns Vim considers a definition for [d and ]d jump commands?
Vim's [d, ]d, [D, and ]D commands search for the "definition" of the keyword under the cursor.
category:
config
tags:
#config
#navigation
#search
#tags
#ex-commands
How do I run a macro as many times as needed until it hits an error and stops automatically in Vim?
Vim macros stop executing the moment any step in the macro causes an error — a failed search, a motion that cannot proceed, or a substitution with no matches.
category:
macros
tags:
#macros
#editing
#normal-mode
How do I search and replace a word while preserving its case variants in Vim?
The vim-abolish plugin by Tim Pope provides the :Subvert command (abbreviated :S), which performs search-and-replace operations that automatically handle every
category:
plugins
tags:
#plugins
#abolish
#search
#substitute
#refactoring
How do I run a command on every line in the quickfix list at once?
:cdo executes an Ex command on every entry in the quickfix list in sequence, visiting each match in turn.
category:
command-line
tags:
#ex-commands
#search
#editing
#quickfix
How do I create a macro that repeats itself automatically until it can no longer proceed?
A recursive macro ends by calling itself, so it loops automatically without you pressing @q repeatedly.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing