How do I search for text that appears after or before a specific pattern without including the pattern in the match?
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine.
category:
search
tags:
#search
#regex
#advanced-search
#lookahead
#lookbehind
How do I apply a recorded macro to every line in a visual selection?
Combining :normal with a visual range lets you replay a macro on each line of a selection individually — far more targeted than recursive macros or @@ repeati
category:
macros
tags:
#macros
#ex-commands
#normal-mode
#visual-mode
How do I navigate through code using tags and the tag stack?
The command jumps to the definition of the keyword under the cursor using a tags file, and jumps back.
category:
navigation
tags:
#navigation
#tags
#code-navigation
#ctags
How do I match only part of a search pattern in Vim using \zs and \ze?
Vim's \zs (start of match) and \ze (end of match) atoms let you control which portion of a pattern is treated as the actual match.
category:
search
tags:
#search
#regex
#substitution
#ex-commands
#editing
How do I make a macro repeat itself until it fails?
A recursive macro calls itself at the end of its recording, causing it to repeat indefinitely until a command inside it fails (like a search hitting the end of
category:
macros
tags:
#macros
#registers
#editing
#automation
How do I find and open a file by name without knowing its full path?
The :find command searches for a file by name across all directories in your path setting and opens it.
category:
buffers-windows
tags:
#buffers
#file-management
#navigation
#workflow
How do I populate the quickfix list from the output of an external shell command?
:cexpr system('grep -rn TODO .')
The :cexpr command evaluates an expression and parses the result as quickfix entries using the current errorformat.
category:
command-line
tags:
#ex-commands
#search
#editing
#buffers
How do I scroll the view left or right without moving the cursor in Vim?
When a line is longer than the window width and wrap is off, Vim can display only part of it.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I limit the height of Vim's insert-mode completion popup menu?
By default, Vim's completion popup menu (the PUM — Pop-Up Menu) can expand to fill the entire screen if there are many candidates.
category:
config
tags:
#config
#completion
How do I insert special characters like ©, ±, or → without leaving Vim?
Vim has a built-in digraph system that lets you insert hundreds of special characters by typing two-character mnemonics.
category:
editing
tags:
#editing
#insert-mode
#special-characters
#unicode
#productivity
How do I edit a recorded macro by modifying it as text in a buffer?
Recorded macros are stored as plain text in registers, but editing them by re-recording is tedious for complex sequences.
category:
macros
tags:
#macros
#registers
#editing
How do I switch between character, line, and block visual selection without reselecting?
v / V / <C-v> (while in visual mode)
When you are already in visual mode and realize you need a different selection type, you do not have to exit and re-enter.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I search for a pattern only within specific columns of a line?
How it works Vim's search patterns support column position constraints using the \%c family of atoms.
category:
search
tags:
#search
#ex-commands
#normal-mode
How do I rename, move, or delete the current file from inside Vim using vim-eunuch?
vim-eunuch (by Tim Pope) adds Unix shell operations as first-class Vim commands.
category:
plugins
tags:
#plugins
#ex-commands
#editing
How do I increment and decrement dates, times, and other structured sequences in Vim?
<C-a> / <C-x> (vim-speeddating)
vim-speeddating (by Tim Pope) extends Vim's built-in and increment/decrement operators to understand dates, times, roman numerals, and other ordered sequences.
category:
plugins
tags:
#plugins
#editing
#normal-mode
How do I filter buffer contents through an external shell command?
The :%!{cmd} command pipes the entire buffer through an external shell command and replaces the buffer contents with the command's output.
category:
command-line
tags:
#editing
#ex-commands
#shell
#filtering
#productivity
How do I view the list of positions I have jumped to in Vim?
How it works Vim keeps a jump list that records your cursor position every time you make a jump.
category:
navigation
tags:
#navigation
#ex-commands
#normal-mode
How do I apply a macro to every line in a specific range without running it manually each time?
The :[range]normal @q command replays the macro in register q on every line within a given range.
category:
macros
tags:
#macros
#normal-mode
#ex-commands
#ranges
How do I configure Vim to auto-save files when I switch away?
:set autowriteall and autocmd FocusLost * silent! wa
How it works Vim can be configured to automatically save your files when you switch to another window or application.
category:
config
tags:
#editing
#buffers
How do I make a macro that finds and operates on specific patterns?
qq /pattern<CR> {commands} q
By incorporating a search command inside a macro, you can make it jump to the next occurrence of a pattern before performing its edits.
category:
macros
tags:
#macros
#search
#recording
#workflow
#advanced