How do I join a wrapped paragraph into one line without manual cursor moves?
vipJ
When text is hard-wrapped for readability in git diffs or markdown source, you sometimes need the paragraph as a single line for refactoring, search, or export.
vipJ
When text is hard-wrapped for readability in git diffs or markdown source, you sometimes need the paragraph as a single line for refactoring, search, or export.
:'<,'>normal! I//
Visual Block insert (I.
:'>,'<normal @q
Running a macro over a range usually goes top to bottom, but that can break when the macro inserts or deletes lines.
macros #macros #ex-commands #visual-mode #normal-mode #refactoring
:packadd justify | :'<,'>Justify 72
Vim can wrap text, but full left-and-right justification is a different task.
plugins #plugins #formatting #visual-mode #text-manipulation
:set mousemodel=extend
If you use the mouse occasionally in Vim, mousemodel=extend makes selection behavior much more predictable.
vitU
When editing markup-heavy files, you often need to transform only the tag contents while preserving the surrounding structure.
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.
:'<,'>normal! .
When you already made one correct edit, replaying it is usually safer than retyping it by hand.
:'<,'>s/\%V\s\+$//
Sometimes you need to clean alignment artifacts in a rectangular region without touching the rest of each line.
visual-mode #visual-mode #substitution #regex #formatting #editing
gN
Most users know gn for selecting the next search match, but its counterpart gN is the real power move when you need to work backward through matches.
visual-mode #visual-mode #search #motions #editing #normal-mode
f{vi{U
When editing structured text, you often need to transform content inside delimiters without touching the delimiters themselves.
:'<,'>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
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.
:set virtualedit=block,onemore
virtualedit controls whether the cursor can move to positions that do not yet contain text.
:
In Visual mode, typing : does more than open the command line: Vim automatically inserts the exact selection range as '.
:'<,'>sort n /\d\+/
Plain :sort n is useful, but it only works when the numeric key starts at the beginning of each line.
visual-mode #visual-mode #sorting #ex-commands #text-processing
:'<,'>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
:'<,'>normal! A;
Visual selections are not just for direct operators; they also define an Ex range.
visual-mode #visual-mode #normal-mode #editing #ex-commands #automation
gv=gv
When you are iterating on indentation, repeating selection steps is wasted motion.
visual-mode #visual-mode #indentation #editing #formatting #workflow
g<C-x>
Most people know decrements one number under the cursor, but g in Visual mode performs a sequential decrement across the selection.