How do I gather all matches from the current file into a location list without moving the cursor?
When you want a searchable list of matches without leaving your current editing context, :lvimgrep is a strong alternative to regular / navigation.
category:
search
tags:
#search
#quickfix
#location-list
#ex-commands
How do I open the current file at a previous Git revision with vim-fugitive?
When you are deep in a refactor, you often need to compare the current buffer with an older version of the same file.
category:
plugins
tags:
#plugins
#git
#fugitive
#buffers
#history
How do I remove accidental Enter keystrokes from a recorded macro?
:let @q = substitute(@q, '\n', '', 'g')
A common macro failure mode is accidentally hitting while recording.
category:
macros
tags:
#macros
#registers
#debugging
#vimscript
How do I write a Vim macro that automatically repeats until it fails?
A recursive macro is one that calls itself as its final action, causing it to repeat indefinitely until any command in the body fails (e.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I run a normal mode command that bypasses all user-defined key mappings?
The :normal! command (abbreviated :norm!) executes a sequence of Normal mode keystrokes while completely ignoring user-defined mappings and abbreviations.
category:
command-line
tags:
#ex-commands
#normal-mode
#macros
#scripting
How do I jump to a specific column number on the current line?
The command (pipe character) moves the cursor to a specific column number on the current line.
category:
navigation
tags:
#navigation
#motions
#columns
#normal-mode
How do I anchor a search or substitution pattern to the current cursor position?
The \%# atom in Vim's regex engine matches the exact position of the cursor — zero-width, between characters.
category:
search
tags:
#search
#normal-mode
#ex-commands
#editing
How do I sort a range of lines by piping them through an external sort command using the ! operator?
The ! operator in Vim filters a motion's text through an external shell command, replacing it with the output.
category:
editing
tags:
#editing
#motions
#ex-commands
How do I run a command on every file in the quickfix list?
:cdo s/old/new/g | update
The :cdo command executes a given command on every entry in the quickfix list.
category:
command-line
tags:
#command-line
#quickfix
#batch-editing
#search
#multi-file
How do I search for tag definitions using a regex pattern instead of an exact name?
When working with ctags, you typically jump to exact tag names with .
category:
navigation
tags:
#navigation
#search
#ex-commands
How do I quickly jump between function definitions or top-level blocks in a source file?
The [[ and ]] commands navigate between top-level code blocks — specifically, lines where { appears in column 1.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I create a self-repeating recursive macro that runs until it reaches the end of the file?
A recursive macro calls itself at the end of its recording, causing it to repeat automatically until an error — such as reaching the end of the file — stops
category:
macros
tags:
#macros
#registers
#editing
How do I make Vim's indent commands always align to a clean shiftwidth boundary?
shiftround causes indent commands (>, always adds exactly shiftwidth spaces to whatever indentation the line already has With shiftround: > rounds up to the nex
category:
config
tags:
#config
#indentation
#editing
How do I resolve a 3-way merge conflict by pulling changes from a specific buffer in diff mode?
When Vim's diff mode has three or more buffers open, :diffget (or do) without an argument is ambiguous — Vim cannot determine which buffer to pull from.
category:
buffers-windows
tags:
#buffers
#windows
#ex-commands
How do I open or close folds one level at a time across the entire file?
The zr and zm commands let you incrementally adjust the global fold depth across the entire buffer — one level at a time.
category:
editing
tags:
#folding
#navigation
#normal-mode
How do I run a Vim command without adding entries to the jump list?
:keepjumps is a command modifier that suppresses any jump list updates caused by the command that follows it.
category:
editing
tags:
#ex-commands
#navigation
#macros
#editing
How do I apply a recorded macro to a specific set of files using the argument list?
:argdo execute 'normal @q' | update
:argdo runs an Ex command on every file in Vim's argument list (the arglist).
category:
macros
tags:
#macros
#ex-commands
#editing
How do I prevent accidental edits to a buffer by making it completely read-only?
:set nomodifiable locks a buffer so that no changes can be made at all — not even temporary ones.
category:
buffers-windows
tags:
#buffers
#editing
#normal-mode
#ex-commands
How do I find all files matching a pattern across all directories in Vim's runtimepath?
globpath(&rtp, 'pattern')
globpath() is a Vimscript function that searches all directories in a given path list for files matching a glob pattern.
category:
config
tags:
#ex-commands
#normal-mode
How do I write a Vim search pattern that matches any character including newlines for multi-line searches?
The \ modifier in Vim extends any character class or atom to also match newlines.
category:
search
tags:
#search
#regex
#multiline
#patterns