How do I select or operate on the entire buffer as a text object?
ggVG
While Vim doesn't have a built-in "entire buffer" text object, the ggVG sequence achieves it: go to the first line, enter line-wise visual mode, then select to
ggVG
While Vim doesn't have a built-in "entire buffer" text object, the ggVG sequence achieves it: go to the first line, enter line-wise visual mode, then select to
:earlier 5m
Vim's :earlier and :later commands let you travel through your undo history using time-based offsets — not just individual changes.
:vimgrep /pattern/g **/*.ext
The :vimgrep command searches for a pattern across multiple files and loads the results into the quickfix list.
* 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.