How do I show context lines around each match when using the :global command?
:g/pattern/z#.5
The :global command is great for finding lines matching a pattern, but by default it only shows the matching lines themselves.
2125 results for "i" a""
:g/pattern/z#.5
The :global command is great for finding lines matching a pattern, but by default it only shows the matching lines themselves.
:m.+1 and :m.-2
The :move (:m) command relocates a line to a new position without cutting and pasting.
zz
The zz command scrolls the window so that the current cursor line appears in the middle of the screen.
:set spell
The :set spell command activates Vim's built-in spell checker, which highlights misspelled words directly in your buffer.
:TestNearest
The vim-test plugin by Janko Marohnić provides a universal interface for running tests from within Vim.
:noautocmd {command}
The :noautocmd prefix (abbreviated :noa) suppresses all autocommand events for the duration of the following command.
command-line #ex-commands #autocommands #performance #command-line #scripting
:set colorcolumn=80,120
colorcolumn highlights one or more screen columns to serve as a visual ruler.
<C-w>P
The preview window is a special auxiliary split — usually at the top — opened by commands like :ptag, :pedit, and omni-completion to display reference infor
:set title
Enabling title tells Vim to update the terminal window's title bar with information about the current file.
b
The b command moves the cursor backward to the beginning of the previous word.
:%center 80
Vim has three built-in Ex formatting commands — :left, :center, and :right — that align text within a specified column width.
:cdo keeppatterns s/\<foo\>/bar/gec | update
When quickfix already contains precise targets, :cdo gives you a safer multi-file replace loop than broad project substitutions.
command-line #command-line #quickfix #substitute #refactoring
:set commentstring=//\ %s
The commentstring option controls the template Vim uses to represent commented-out lines.
<Leader>tm
The vim-table-mode plugin by Dhruva Sagar turns Vim into a powerful table editor that automatically formats and aligns table columns as you type.
:'<,'>s/\%V\s\+$//
Sometimes you need to clean alignment artifacts in a rectangular region without touching the rest of each line.
visual-mode #visual-mode #substitution #regex #formatting #editing
zx
The zx command resets and recomputes all folds in the current window based on the current foldmethod.
g_
g moves the cursor to the last non-blank character of the current line — skipping trailing spaces and tabs.
zg and zw
When Vim's spell checker marks a word as incorrect but it is intentionally spelled that way (a name, abbreviation, or domain-specific term), you can permanently
dap / dip
The dap and dip commands use Vim's paragraph text objects to delete an entire block of contiguous text in a single motion.
editing #editing #text-objects #normal-mode #delete #motions
inoremap <Left> <C-g>U<Left>
In insert mode, any cursor movement — including arrow keys, Home, and End — causes Vim to split the undo block at that point.