How do I quickly replace all occurrences of the word under my cursor?
* then :%s//new/g
Pressing searches for the word under the cursor, which also loads it into the search register.
Search Vim Tricks
Searching...* then :%s//new/g
Pressing searches for the word under the cursor, which also loads it into the search register.
:'<,'>s/\%Vold/new/g
The \%V atom restricts a search pattern to match only within the visual selection area, including visual block selections.
:%s/\<word\>/\u&/g
Vim's substitute command supports case conversion modifiers in the replacement string.
:tabnew | lcd /path/to/project
Vim's :lcd (local change directory) sets the working directory per window.
buffers-windows #buffers #windows #tabs #workflow #project-management
<C-r>/
Vim stores your last search pattern in the / register.
0 or ^ at start of macro
A common macro pitfall is assuming the cursor starts at a specific column.
:%sort u
The :sort u command sorts all lines in the file and removes duplicate lines in one operation.
command-line #command-line #ex-commands #editing #text-manipulation #sort
g&
The g& command repeats the last substitute command across the entire file.
:let @q then use in nnoremap
Macros are stored in registers as plain keystroke strings.
zt / zb
The zt and zb commands scroll the viewport so the current cursor line appears at the top or bottom of the screen respectively, without moving the cursor.
:%!python3 -m json.tool
The :%! command pipes the entire buffer through an external command and replaces it with the output.
command-line #command-line #shell #formatting #json #workflow
:cdo s/old/new/g | update
The :cdo command executes a given command on every entry in the quickfix list.
command-line #command-line #quickfix #batch-editing #search #multi-file
:cq
The :cq command quits Vim and returns a non-zero exit code to the calling process.
<C-x><C-o>
The keystroke triggers omni completion, Vim's built-in language-aware completion system.
gx
The gx command opens the URL, file path, or identifier under the cursor using the system's default handler.
navigation #navigation #netrw #workflow #browser #normal-mode
<C-r><C-o>"
The {register} sequence in insert mode pastes register contents literally — without triggering auto-indentation, abbreviations, or mappings.
gj / gk
When a long line wraps across multiple screen rows, the regular j and k motions skip the entire logical line.
"1p ... "2p ... "9p
Vim maintains a numbered register history from "1 through "9 that stores your last 9 deletes and changes.
( / ) / { / }
Vim treats sentences and paragraphs as first-class navigation units.
navigation #navigation #motions #text-objects #prose #editing
:make
The :make command runs your build tool and parses its output into the quickfix list, letting you jump directly to each error location.
command-line #command-line #quickfix #build #workflow #programming