How do I return to normal mode from absolutely any mode in Vim?
<C-\><C-n>
While works to leave insert or visual mode, it does not work in every situation — particularly in terminal mode (:terminal), where is consumed by the running
<C-\><C-n>
While works to leave insert or visual mode, it does not work in every situation — particularly in terminal mode (:terminal), where is consumed by the running
zf{motion}
Vim supports several fold methods, but manual folding with zf gives you precise control over exactly which lines to collapse.
g<C-g>
While shows basic file info (filename, line count, position), g provides a much more detailed statistical breakdown of your file or visual selection.
<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.
<C-v>jj$A;
Visual block mode normally selects a fixed-width column, which makes appending tricky when lines have different lengths.
o (in Visual mode)
When you make a Visual selection in Vim, the cursor sits at one end while the other end is anchored.
v3aw
In visual mode, repeating text object motions progressively expands the selection.
>gv
Normally, pressing > in visual mode indents the selection but exits visual mode, requiring you to press gv to reselect.
"ayv
Using named registers with visual mode lets you store multiple independent snippets simultaneously.
: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.
:set virtualedit=block
By default, Vim's visual block mode () is limited by line length — if some lines are shorter than others, the block selection gets ragged.
<C-v>$
In visual block mode, pressing $ extends the selection to the end of every line, even when lines have different lengths.