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.
432 results for "visual mode"
:'<,'>move'>+1 or :'<,'>move'<-2
How it works Vim's :move command lets you relocate lines to a different position.
:'<,'>!{cmd}
After making a visual selection and entering the command line with :, Vim automatically inserts the range ' for the selection.
"ayv
Using named registers with visual mode lets you store multiple independent snippets simultaneously.
o and O
In visual-block mode (), pressing o moves the cursor to the diagonally opposite corner of the selection, and O moves it to the other end of the same row (flippi
/\%V
The \%V pattern atom restricts a search to the region spanned by the last visual selection.
:'<,'>sort /\%V.*$/
When you need to sort records by a substring that starts at a visual column, Vim can do it without external tools.
visual-mode #visual-mode #sorting #ex-commands #text-processing
:'<,'>sort!
The sort! command sorts the selected lines in reverse (descending) order.
> 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
/\%Vpattern
The \%V atom restricts a search pattern to only match inside the most recent visual selection.
<C-v>jjxp
Visual block mode lets you select, cut, and paste rectangular columns of text.
<C-v>$
In visual block mode, pressing $ extends the selection to the end of every line, even when lines have different lengths.
:'<,'>copy'>
How it works The :copy command (or its abbreviation :t) duplicates lines to a specified destination.
viw
How it works The command viw selects the word under the cursor in visual mode.
gvV
gv is well known for reselecting the previous visual area, but pairing it with V is a practical upgrade when your next action needs linewise semantics.
:'<,'>sort /\%20v/
When lines contain aligned columns, plain :sort often gives the wrong order because it compares from column 1.
visual-mode #visual-mode #sorting #text-processing #command-line
I{text}<Esc>
When you need to add the same prefix to many adjacent lines, Visual Block insert is faster and safer than repeating macros or substitutions.
v_o
When you start a visual selection, the cursor is at one end and the anchor is at the other.
S"
The vim-surround plugin provides the S command in visual mode to wrap any selection with a delimiter pair.
:'<,'>g/let /normal! A;<CR>
When you need a structural edit in part of a file, Visual mode ranges combine well with :global and :normal!.
visual-mode #visual-mode #command-line #ex-commands #editing
:s/^/\=line('.') - line("'<") + 1 . '. '/
When you need to quickly number a set of lines — such as TODO items, steps, or bullet points — you can use a visual selection combined with a substitution e
visual-mode #visual-mode #editing #ex-commands #formatting #substitute