How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?
\@=
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
414 results for "G"
\@=
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
:cfdo %s/old/new/ge | update
When you grep across your project and want to perform a search-and-replace on every file that matched, :cfdo is the most efficient approach.
command-line #quickfix #substitute #search #ex-commands #editing
:bprev
The :bprev (or :bp for short) command switches to the previous buffer in Vim's buffer list.
:%s/old/new/gc
Adding the c flag to a substitute command makes Vim pause at every match and ask you whether to replace it.
:noautocmd write
The :noautocmd modifier (abbreviated :noa) runs any subsequent Ex command while temporarily disabling all autocommand events.
:'<,'>sort
The :'sort command sorts the currently selected lines in visual mode alphabetically.
<C-v>$A
When you need to append text to the end of several lines that have different lengths, visual block mode with $ is the key.
:keeppatterns
Normally, any command that uses a pattern — including :substitute, :global, and :vimgrep — replaces the current search register @/ with the new pattern.
<C-v>u{hex}
In insert mode, pressing followed by u and a 4-digit hexadecimal codepoint inserts the corresponding Unicode character directly into the buffer.
". / "% / ": / "# registers
Vim has four read-only special registers that automatically contain useful contextual information.
registers #registers #special-registers #workflow #productivity
:set statusline=%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
Vim's built-in statusline option lets you build a custom status bar that displays exactly the information you want — without any plugin.
<C-r>=system("date")<CR>
The expression register (=) is one of Vim's most powerful yet underused features.
:nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
Expression mappings use the flag to evaluate a Vimscript expression at the time the key is pressed.
:let @/ = 'pattern'
Writing to the @/ register via :let @/ = 'pattern' sets Vim's last-search pattern directly — without performing a search or moving the cursor.
gp
The standard p command pastes text after the cursor but leaves the cursor at the beginning of the pasted text.
<C-w>}
How it works The } command opens a preview window showing the tag definition of the word under your cursor.
"qp
Macros are stored as plain text in named registers.
gl{motion}{char}
vim-lion (by Tom McDonald) adds gl and gL as alignment operators.
\v
Vim's default regex mode ("magic") requires backslashes before many special characters: \(, \ , \+, \{.
b
The b command moves the cursor backward to the beginning of the previous word.