How do I create an incrementing number sequence from identical numbers in Vim?
g<C-a> in visual mode
When you have multiple lines with the same number and want to turn them into a sequence (1, 2, 3.
g<C-a> in visual mode
When you have multiple lines with the same number and want to turn them into a sequence (1, 2, 3.
gcc / gc{motion}
The vim-commentary plugin by Tim Pope provides a simple, operator-based way to comment and uncomment code.
:'<,'>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.
:'<,'>norm @q
When you visually select lines and then type a : command, Vim automatically inserts ' (the visual range marks) into the command line.
<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.
O in visual block mode
In visual block mode (), pressing O (uppercase) moves the cursor to the diagonally opposite corner of the rectangular selection.
vi<
The vi).
~ (in visual mode)
In visual mode, pressing ~ toggles the case of every character in the selection.
zf (in visual mode)
In visual mode, pressing zf creates a manual fold from the selected lines.
:'<,'>m'>+1
The :m command with the visual range moves selected lines.
U (in visual mode)
In visual mode, pressing U converts all selected text to uppercase.
y (in visual mode)
In visual mode, pressing y yanks (copies) the selected text into the default register.
c""<Esc>P
Without a surround plugin, you can manually wrap selected text by changing it, typing the delimiters, and pasting the original text back.
v/pattern<CR>
Starting a search while in visual mode extends the selection to the search match.