How do I yank a visual selection to a specific named register?
"ayv
Using named registers with visual mode lets you store multiple independent snippets simultaneously.
"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.
:'<,'>s/pattern/replacement/g
When you make a visual selection and then type :, Vim automatically inserts ' as the range — the marks for the start and end of the last visual selection.
vaB
The aB text object (around Block) selects everything from the matching { to the closing } — including the braces themselves.
vis
The is (inner sentence) text object selects the sentence the cursor is in — excluding any leading or trailing whitespace that separates sentences.
va"
Vim's text objects let you select structured regions of text with two-keystroke shortcuts.
vas
The vas command visually selects the current sentence, including surrounding whitespace.
<C-v>I#<Esc>
Vim's Visual Block mode lets you prepend characters (like comment markers) to multiple lines simultaneously.
!sort
Vim can pipe a visual selection through any shell command and replace the selection with the command's output.
visual-mode #visual-mode #ex-commands #external-commands #filtering
U
In visual mode, pressing U converts all selected characters to uppercase and u converts them to lowercase.