Add a prefix to several lines
<C-v>2jI# <Esc>
Example
Normal mode on a in alpha. Lines: alpha, beta, gamma.
alpha
beta
gammaCursor on line 1, column 1- <C-v>2j First column selected · three-line Visual block
- I# <Esc> Prefix all three lines with # and a space
# alpha
# beta
# gammaCursor on line 1, column 1Details & Vim help
Insert the same text at the left edge of a Visual block.
Comment or label aligned lines in one insertion.
The repeated insertion appears after leaving Insert mode. Short lines before the block’s start can be skipped; tabs and virtualedit affect column behavior. Ctrl-v may be remapped by a platform configuration.
Try it in Vim
- Start at the a in alpha and press Ctrl-v, then 2j.
- Press uppercase I and type # followed by a space.
- Press <Esc> to apply the insertion to the selected rows.