How do I see a live preview of substitutions as I type in Neovim?
:set inccommand=split
Neovim's inccommand option provides real-time visual feedback as you type substitution commands.
:set inccommand=split
Neovim's inccommand option provides real-time visual feedback as you type substitution commands.
<C-v>jjr<C-k>12
Visual block mode combined with the replace command and digraph input lets you replace a column of characters with special Unicode characters.
:'<,'>!awk '{print toupper($0)}'
Vim can pipe any visual selection through external Unix commands and replace the selection with the output.
visual-mode #visual-mode #external-command #awk #text-transformation
:'<,'>retab!
The :retab! command converts between tabs and spaces based on your expandtab setting.
g?
Vim has a built-in ROT13 encoding operator accessible via g?.
visual-mode #visual-mode #encoding #rot13 #text-transformation
:'<,'>!awk '{printf "%-20s %s\n", $1, $2}'
By piping a visual selection through awk with printf formatting, you can align columns to fixed widths.
visual-mode #visual-mode #formatting #alignment #external-command
<C-v>j$A;<Esc>
When lines have varying lengths, a normal visual block selection stops at the shortest line.
<C-v>jjI\=printf('%02d ', line('.')-line("'<")+1)<CR><Esc>
By combining visual block insert with Vim's expression register, you can insert dynamically computed line numbers at the start of each selected line.
visual-mode #visual-mode #block-mode #line-numbers #expression-register
<C-v>jjxp
Visual block mode lets you select, cut, and paste rectangular columns of text.
/\%5l\%10cpattern
Vim provides position-matching atoms that constrain where a pattern can match based on line numbers, column positions, or virtual columns.
/pattern\{3}
Vim supports counted quantifiers that let you specify exactly how many times a pattern should repeat.
/pattern\@<=match
Vim supports zero-width assertions (lookahead and lookbehind) in its regex engine, allowing you to match text based on what precedes or follows it without inclu
:%s/\d\+/\=submatch(0)+1/g
Vim's expression replacement (\=) in substitutions lets you perform arithmetic on matched text.
:%s/\(\w\+\) \(\w\+\)/\2 \1/g
Vim's substitute command supports captured groups (back-references) using \( and \), allowing you to capture parts of a match and rearrange them in the replacem
/[\x00-\x1f]
Files sometimes contain hidden control characters that cause subtle bugs.
/pattern\_s\+next
Vim's regular expressions support multi-line matching through underscore-prefixed atoms.
/foo\|bar\|baz
Vim's search supports alternation with the \ operator, allowing you to find any one of several patterns in a single search.
/[[:digit:][:upper:]]
Vim supports POSIX character classes inside bracket expressions, providing a portable and readable way to match categories of characters.
"+q{keys}q
You can record macros into any register, including the system clipboard (+).
:echo @/
The / register holds the most recent search pattern.