What Is Visual Block Mode?#
Normal visual mode (v) selects characters in a stream. Visual line mode (V) selects whole lines. Visual block mode (Ctrl-V) selects a rectangle — a column of text spanning multiple lines.
This lets you operate on vertical slices of a file: insert a prefix on 20 lines at once, delete a column of data, replace aligned text, or reindent a block — all without regex or macros.
Entering Visual Block Mode#
Press Ctrl-V (sometimes shown as <C-v>) in normal mode. You’ll see -- VISUAL BLOCK -- in the status bar.
Then move to expand the selection:
| Key | Movement |
|---|---|
j / k | Extend down / up |
l / h | Extend right / left |
w | Extend by word |
$ | Extend to end of each line |
} | Extend to next blank line |
G | Extend to end of file |
The selection is always rectangular — it doesn’t follow line length.
Ctrl-V might be intercepted for paste. If that happens, use Ctrl-Q instead, or remap your terminal’s paste shortcut.Insert Text on Multiple Lines#
This is the most common use case — adding a prefix or indent to a block of lines.
Steps:
- Place cursor at the starting position
Ctrl-Vto enter visual block modej(or movement) to extend the selection downI(capital I) to insert before the block- Type your text
Esc— the text appears on all selected lines
Example — add # to comment out lines:
Before:
server_name example.com
listen 80
root /var/www/htmlWith cursor on line 1 column 1: Ctrl-V, 2j, I, # , Esc
After:
# server_name example.com
# listen 80
# root /var/www/htmlAppend After a Block#
Use A (capital A) instead of I to append text after the selection:
Ctrl-V, select the block$to extend to end of line (important for ragged lines)Ato append- Type your text
Esc
Example — add a trailing comment:
Before:
port = 8080
host = localhost
debug = trueSelect all lines with Ctrl-V, 2j, $, A, # default, Esc
After:
port = 8080 # default
host = localhost # default
debug = true # defaultDelete a Column#
Select a rectangle and press d (or x) to delete it.
Example — remove line numbers from pasted output:
Before:
1 fn main() {
2 println!("hello");
3 }Place cursor on line 1 column 1, Ctrl-V, 2j, 4l, d
After:
fn main() {
println!("hello");
}Replace a Block#
Select a rectangle and press r followed by a character to replace every character in the selection.
Example — redact a column:
Before:
user password role
alice s3cr3t! admin
bob hunter2 user
carol p@ssw0rd userSelect the password column: position cursor on s of s3cr3t!, Ctrl-V, 2j, 7l, r, *
After:
user password role
alice ******** admin
bob ******** user
carol ******** userChange a Block#
Select a rectangle and press c to delete the selection and enter insert mode. What you type replaces the block on every line.
Example — change a repeated value:
Before:
ENV=production
ENV=production
ENV=productionSelect production on all lines: Ctrl-V, 2j, e, c, staging, Esc
After:
ENV=staging
ENV=staging
ENV=stagingShift and Indent a Block#
You don’t always need visual block mode for indentation — visual line mode (V) with > and < works well. But visual block is useful when you want to indent only part of a line or a precise column.
Indent lines with visual line mode:
V, select lines, > to indent, < to outdentInsert spaces at a specific column with block mode:
Ctrl-V, select the column position across linesI, type spaces,Esc
Working with Aligned Data#
Visual block mode shines when editing tabular or column-aligned text.
Reorder Columns#
Combine block select with delete and paste:
- Select a column with
Ctrl-V dto cut it- Move to the destination
pto paste the block
Align Equals Signs#
If you have misaligned assignments:
name = "alice"
port = 8080
max_connections = 100
debug = trueSelect the column after the longest key, use I to add spaces where needed. Or use block delete to remove extra spaces first, then re-add them uniformly.
Number a List#
You can use g Ctrl-A to create incrementing numbers after inserting a column of identical starting values:
- Write a
0(or1) at the start of each line using block insert - Select all the numbers with
Ctrl-V g Ctrl-Ato increment them sequentially
Before (after inserting 0. on each line):
0. First item
0. Second item
0. Third item
0. Fourth itemSelect the column of 0s, then g Ctrl-A:
1. First item
2. Second item
3. Third item
4. Fourth itemPractical Scenarios#
Comment/Uncomment a Block of Code#
Comment out:
Ctrl-V → select lines → I → // → EscUncomment (remove // ):
Ctrl-V → select lines → 2l (to cover "// ") → dAdd Quotes Around a Column of Values#
Before:
alice
bob
carolAdd opening quote: Ctrl-V, 2j, I, ", Esc
Add closing quote: Ctrl-V, 2j, $, A, ", Esc
After:
"alice"
"bob"
"carol"Fix Indentation on Pasted Code#
When code pastes with wrong indentation, select the misaligned block with Ctrl-V and either delete extra spaces or insert missing ones.
Convert Spaces to Tabs (or Vice Versa) in a Region#
Select the leading whitespace column and replace it:
Ctrl-V, extend down across lines- Select the whitespace width
c, type the replacement whitespace,Esc
Tips#
$makes ragged lines uniform. When lines have different lengths,$extends the selection to the end of every line, soAappends at the true end of each line rather than at a fixed column.Otoggles the cursor corner. While in visual block mode, pressingO(capital O) moves the cursor to the opposite corner of the selection. This lets you adjust the selection from either end.gvreselects. If you lose your selection,gvbrings back the last visual selection — works for block mode too.Dot repeat works. After a block insert/append,
.repeats it. Useful if you need to apply the same edit to another block of lines.:commands apply to block selections. If you press:while in visual block mode, you get:'<,'>which applies commands to the selected line range (not the block rectangle specifically). For true column operations, use the block operators (I,A,d,c,r).
Quick Reference#
| Action | Keys |
|---|---|
| Enter visual block mode | Ctrl-V |
| Insert on all lines | Ctrl-V, select, I, type, Esc |
| Append on all lines | Ctrl-V, select, $, A, type, Esc |
| Delete a column | Ctrl-V, select, d |
| Replace characters in block | Ctrl-V, select, r, char |
| Change a block | Ctrl-V, select, c, type, Esc |
| Extend to end of lines | $ |
| Toggle cursor corner | O |
| Reselect last selection | gv |
| Sequential numbering | Select numbers, g Ctrl-A |


