Visual Mode 1. Introduction to Visual Mode commands
- Enter in normal mode
v (lowercase), enter the character selection mode, you can move the cursor, where the cursor will be selected. The selection is deselected when the V-meeting is pressed again.
- In normal mode input
Shift+v (lowercase), enter the line selection mode, press V will be the entire row selection, you can move up and down the cursor select more rows, again, press once Shift+v can be deselected.
- In normal mode
Ctrl+v (lowercase), this is the area selection mode, you can select the rectangular region, and then cancel the selection by one time Ctrl+v .
- Enter
d Delete Selection area contents in Visual mode
- Enter
y Copy selection area contents in Visual mode
2. Visual Mode Command Practice
Copy the practice file to the current directory
$ cp /etc/protocols .
Open the practice file
$ vim protocols
- In normal mode
9G , jump to line 9th, enter Shift+v (lowercase v), enter the visual mode for row selection, select 5 rows, press >> indent, indent 5 rows into oneshiftwidth
- Enter in normal mode
Ctrl+v (lowercase v), enter visual mode for rectangular area selection, select the first column character and then x delete the whole column
Vim Visual mode