1. Execution and departure of Vi
2. The operating mode of Vi
Command Mode
Insert Mode
Last Line Mode
|
Vi's mode of operation |
i Insert, enter text from the current cursor position
Command Mode function key introduction
Command Description
k or ↑ Move the cursor up one space
l or → Move the cursor one space right
Ctrl+B Scroll backward one screen
Ctrl+F Scroll forward one screen
Ctrl+U Scroll half screen backward
Ctrl +D Scroll forward half a screen
Ctrl+E Scroll backward half a line
Ctrl+Y Scroll forward half a line
Number 0 Move the cursor to the beginning of the line
G Move the cursor to the beginning of the last line
W or w Move the cursor to the bottom The prefix of a word e Moves
the cursor to the end of the next word
b Moves the cursor to the prefix of the previous word
To the 7th character of the line {cursor moves forward one paragraph } cursor moves backward one paragraph
H Move to the top of the screen
M Move to the middle of the screen
L Move to the bottom of the screen
o Insert a line below the
cursor O Insert a line above the cursor
~ Change letter case
2. Copy text
Command Description
y+y Copy the entire line
y+w Copy a single word Number
+y+y 5+y+y means copy the current cursor position and the following 5 lines together
Number +y+w 5+y+w means copy the current cursor position and the following 5 words together
p Paste Post
3. Delete text
Command Description
d+↑ can delete the line at the cursor position and the previous line at the same time
Last Line Mode
Replenish
Under GUI:
(1) Press i to enter insert mode
(2) Use the mouse to drag to invert the selection to be pasted, press the left mouse button to copy the selected block to the buffer
(3) Then move the cursor to the place to be pasted, press The middle mouse button (two-button mouse can press the left and right buttons at the same time), paste the buffer content.
In a plain text terminal:
(1) Select a text block, use v to enter visual mode; move the cursor key to select the content
(2) copy the selected block to the buffer, use y; copy the entire line, use yy
(3) Cut the selected block to the buffer, use d; cut the entire line and use dd
(4) to paste the content in the buffer, use p
to open the second file in the same editing window, use :sp [filename]
in multiple editors To switch between files, use Ctrl+w
to add a number in front of the command to indicate the number of repetitions, and add a letter to indicate the buffer name used.
For help, use :help [content or command]
a) Undo the last edit operation. ====> U
b) Repeat the last editing operation. ====》.
c) Revert the undone editing operation. ====> Ctrl + R
For more Vi commands, see Ubuntu Command Tips