How to select text in Visual mode in Vim
vVCtrl-vPress v to start selecting characters, V for whole lines and Ctrl-v for a block. Move the cursor to grow the selection.
Then press an operator: d deletes the selection, y copies it and c changes it. Esc cancels the selection.
Worked example
Delete the two lines in the middle.
V selects the whole line, wherever the cursor is on it. j adds the next line.
Commands
- v
- Select characters.
- V
- Select whole lines.
- Ctrl-v
- Select a block, a rectangle of columns.
- o
- Move to the other end of the selection.
- c
- Change the selection.
- U
- Make the selection upper case.
Type on many lines at once
In a block selection, I inserts at its left edge and A at its right edge. The text appears on every selected line when you press Esc. Press $ first to append at the end of each line, even when the lines have different lengths.
- Ctrl-v…I
- Insert at the left edge of every line.
- Ctrl-v…$A
- Append at the end of every line.
Exceptions
- For a piece with a clear shape, a text object is often quicker: ci" instead of selecting the quoted text by hand.
- In some browsers and terminals, Ctrl-v pastes instead. In this site's editor it starts a block selection.