How do I select to the end of each line in visual block mode?
Answer
<C-v>$
Explanation
In visual block mode, pressing $ extends the selection to the end of every line, even when lines have different lengths. This creates a ragged right-edge selection that follows each line's end, unlike a fixed-width rectangular block.
How it works
- Enter visual block mode with
<C-v> - Select lines downward with
j - Press
$to extend to the end of each line - The selection now covers from the cursor column to the end of every selected line, regardless of line length
Example
Given these lines of different lengths with cursor at column 5:
hello world
hi
hello there friend
hey
Pressing <C-v>3j$ selects:
[o world]
[]
[o there friend]
[]
Now pressing A; and <Esc> appends a semicolon to the end of each line.
Tips
- Combine with
Ato append text at the end of lines with different lengths - Use
dafter selecting to delete from a column to end-of-line on all selected lines - This is the key difference between
<C-v>l(fixed width) and<C-v>$(to end of line)