- 命令行模式command mode
控制屏幕光标的移动,字符、字或行的删除,移动复制某区段及进入Insert mode下,或者到 last line mode。
- 插入模式Insert mode
只有在Insert mode下,才可以做文字输入,按「ESC」键可回到命令行模式。
- 底行模式(last line mode)
将文件保存或退出vi,也可以设置编辑环境,如寻找字符串、列出行号……等。
1, common commands
instruction | |
---|---|
open a file | vi path / filename |
Edit mode | i |
Line mode | 「ESC」 |
create a new file | vi filename (remember to bring file suffix) |
check the file | cat file (remember to bring file suffix) |
Save the file and exit | The line mode, the: wq |
Force Quit | The line mode, the input: q! |
** saved as a file name | Under the bottom line mode, w filename |
Once the recovery operation | The line mode, press u |
Seek | Under the bottom line mode, such as "/ hello" or "? Hello" |
replace | The line mode, move the cursor to the position of press requires replacement r, can be entered, then exit the alternative mode esc |
2, some of the keys in the bottom row of function modes:
h
Move the cursor left one character
l
Move the cursor right one character
k
Cursor up one line
j
Cursor down one line
^
Move the cursor to the beginning of the line
0
At the beginning of the number "0", move the cursor to the article
G
Move the cursor to the last article
$
Move the cursor to the end of the line
Ctrl+f
Scroll forward
Ctrl+b
Scroll backward
Ctrl+d
The flip ahead half screen
Ctrl+u
Backward half screen
i
Character is inserted before the cursor position
a
It began to increase in a character after the cursor location
O
Insert a new line, beginning from the first line input
ESC
Retreat state from the command input status
x
Delete the character behind the cursor
#x
Delete the cursor after the character #
X
(Upper case X), delete the character before the cursor
#X
Delete characters before the cursor #
dd
Delete line cursor
#dd
# Delete rows from the cursor line number
is
Copy a word at the cursor position
#yw
Copy the cursor position # words
yy
Copy line position of the cursor
#yy
# Copy rows from the cursor line
p
Stick
in
Cancellation
cw
Change the location of the cursor one word
#cw
Change the location of the cursor # words
w filename
Store the file being edited to filename
wq filename
Document storage being edited for the filename, and exit vi
q!
Abandon all changes and exit vi
not set
Show Line Numbers
/or?
Find, enter what you're looking at / after
n
And / or? Be used together, if the content is not looking for keywords that you want to find, press n or backward (with / MS) or forward (with? MS) continue to look until I find it.