How do I move selected lines up or down in visual mode?
:'<,'>move'>+1 or :'<,'>move'<-2
How it works Vim's :move command lets you relocate lines to a different position.
:'<,'>move'>+1 or :'<,'>move'<-2
How it works Vim's :move command lets you relocate lines to a different position.
viw
How it works The command viw selects the word under the cursor in visual mode.
> and <
How it works In visual mode, you can shift selected lines to the right or left using the > and to indent them or or shifts the selected lines one shiftwidth to
gaip=
vim-easy-align is a plugin by Junegunn Choi that makes aligning text around delimiters effortless.
"0p in visual mode
When you paste over a visual selection with p, Vim replaces the selection with the register contents — but it also puts the deleted selection into the unnamed
Va{ or Vi{
The a{ (around braces) and i{ (inside braces) text objects combined with visual mode let you instantly select an entire function body or code block, regardless
visual-mode #visual-mode #text-objects #code-navigation #selection
r{char} in visual mode
In visual mode, pressing r followed by a character replaces every character in the selection with that single character.
o (in visual mode)
While in visual mode, pressing o swaps the cursor to the opposite end of the selection.
ggVG
While Vim doesn't have a built-in "entire buffer" text object, the ggVG sequence achieves it: go to the first line, enter line-wise visual mode, then select to
:'<,'>s/\%Vold/new/g
The \%V atom restricts a search pattern to match only within the visual selection area, including visual block selections.
d<C-v>2j
Vim lets you override the natural type of any motion by pressing v, V, or between the operator and the motion.
editing #editing #motions #visual-mode #advanced #normal-mode
S"
The vim-surround plugin provides the S command in visual mode to wrap any selection with a delimiter pair.
viwp
The viwp command visually selects the word under the cursor and replaces it with the contents of the unnamed register (your last yank or delete).
visual-mode #editing #visual-mode #registers #paste #productivity
<C-v>jjc replacement<Esc>
Visual block mode's change command lets you replace a rectangular column of text across multiple lines in a single operation.
visual-mode #editing #visual-mode #block-mode #normal-mode #productivity
v + repeated iw/aw/i(/a(/ip/ap
Once you enter visual mode, you can progressively expand your selection by typing increasingly larger text objects.
visual-mode #visual-mode #text-objects #editing #selection #productivity
/\%Vpattern
The \%V atom restricts a search pattern to only match inside the most recent visual selection.
`[v`]
The ` [v] sequence visually selects the exact region of text that was last changed, pasted, or yanked into the buffer.
visual-mode #editing #visual-mode #marks #paste #productivity
:'<,'>s/\n/, /g
Vim's J command joins lines with a single space, but sometimes you need a custom separator like a comma, pipe, or semicolon.
editing #editing #ex-commands #visual-mode #substitution #lines
=
Pressing = in visual mode auto-indents the selected lines according to Vim's built-in indentation rules.
visual-mode #editing #visual-mode #indentation #formatting #productivity
<C-v>jj$A text<Esc>
Visual block mode combined with $A lets you append text to the end of multiple lines simultaneously, even when those lines have different lengths.
visual-mode #editing #visual-mode #block-mode #productivity #insert-mode