How do I sort selected lines numerically in visual mode using the first number on each line?
Plain :sort n is useful, but it only works when the numeric key starts at the beginning of each line.
category:
visual-mode
tags:
#visual-mode
#sorting
#ex-commands
#text-processing
How do I auto-indent a block of code in visual selection without specifying a line range?
Pressing = in visual mode re-indents all selected lines according to the current filetype's indent rules — the same engine used by == for a single line, but a
category:
visual-mode
tags:
#visual-mode
#indentation
#editing
#text-objects
How do I select an entire code block from opening brace to closing brace in visual mode?
Pressing V% enters visual line mode on the current line and immediately extends the selection to the line containing the matching bracket or brace.
category:
visual-mode
tags:
#visual-mode
#navigation
#text-objects
#motions
How do I apply a recorded macro to every line in a visual selection?
Combining :normal with a visual range lets you replay a macro on each line of a selection individually — far more targeted than recursive macros or @@ repeati
category:
macros
tags:
#macros
#ex-commands
#normal-mode
#visual-mode
How do I change the case of a specific column of text using visual block mode?
Visual block mode lets you select rectangular regions of text, which means you can target a specific column and apply case changes only to that area.
category:
visual-mode
tags:
#visual-mode
#editing
#text-objects
#formatting
How do I apply my last normal-mode change to every line in a visual selection?
When you already made one correct edit, replaying it is usually safer than retyping it by hand.
category:
visual-mode
tags:
#visual-mode
#editing
#command-line
#automation
How do I run a normal mode command on every line in a visual selection?
After making a visual selection, :norm {commands} executes normal-mode keystrokes on every line in the range.
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
#normal-mode
How do I run the last executed macro across an existing visual line range?
When you already have a useful macro but need to apply it to a specific block of lines, :'normal @@ is a high-leverage pattern.
category:
macros
tags:
#macros
#ex-commands
#visual-mode
#automation
How do I insert the same text at the start of multiple lines using visual block mode?
Visual block mode () lets you select a rectangular region across lines.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I briefly highlight text after yanking it to get visual confirmation of what was copied?
The TextYankPost event fires immediately after any yank operation completes — including y, Y, dd, dw, and any other command that writes to a register.
category:
config
tags:
#config
#autocommands
#registers
#visual-mode
How do I run a global command only on lines within a visual selection?
How it works The :g (global) command is one of Vim's most powerful features.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#search
#editing
How do you select a rectangular column of text?
Press for visual block mode, then use movement keys to select a rectangle.
category:
visual-mode
tags:
#visual
#block
#column
How do I repeat my last change on every line in a visual selection?
The :'norm .
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
#repeat
#dot-operator
How do I insert text at the beginning of multiple lines at once using visual block mode?
Visual block mode's I command lets you type once and have the text inserted at the cursor column across all selected lines simultaneously.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I filter a visual selection through an external shell command?
How it works Vim can pipe selected text through any external shell command, replacing the selection with the command's output.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#editing
#formatting
How do I expand or shrink a visual selection to the next text object boundary?
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.
category:
visual-mode
tags:
#visual-mode
#text-objects
#editing
#selection
#productivity
How do I select a rectangular block past the end of shorter lines in visual block mode?
By default, Vim's visual block mode () is limited by line length — if some lines are shorter than others, the block selection gets ragged.
category:
visual-mode
tags:
#visual-mode
#editing
#config
#indentation
How do I quickly select an entire function body using visual mode?
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
category:
visual-mode
tags:
#visual-mode
#text-objects
#code-navigation
#selection
How do I append text to the end of multiple lines with different lengths in visual block mode?
In visual block mode, pressing $ makes the right edge of the selection "ragged" — it extends to the real end of each line regardless of length.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I send a visual selection to an external command as input without replacing the selected text?
The :'w !{cmd} command writes the visually selected lines to the stdin of an external shell command — without modifying the buffer.
category:
visual-mode
tags:
#visual-mode
#ex-commands
#editing
#normal-mode