VI命令

一、Search Functions 搜索
/exp Go forward to exp 从前往后开始搜索字符exp
?exp Go backward to exp 从后往前搜索字符exp

二、移动或着插入

Move and Insert Text 
:3,8d Delete line 3- 8  删除3到8行
:4,9m 12 Move lines 4-9 to 12把4-9行内容移动到12行
:2,5t 13 Copy lines 2-5 to 13 复制2-5行到13行
:5,9w file Write lines 5-9 to file


三、保存文件退出

Save Files and Exit
:w Write to disk
:w newfile Write to newfile
:w! file Write absolutely
:wq Write and quit
:q Quit editor
:q! Quit and discard 不保存强制退出
:e! Re-edit current file,
Discard buffer

Control Edit Session
:set nu Display line number  设置行号
:set nonu Turn off line number
:set all Show all settings
:set list Display invisible
Characters
:set wm=5 Wrap lines 5 spaces
From right margin
键盘移动命令

Screen/Line Movement
j  Move cursor down
k  Move cursor up
h  Move cursor left
l  Move cursor right
0  Go to line start (zero)
$  Go to line end
G  Go to last file line
Word Movement
w  Go forward 1 word
b  Go backward 1 word
Search Functions
n  Repeat previous search
N  Reverse previous search
Delete Text
x  Delete 1 character
dw  Delete 1 word
dd  Delete 1 line
D  Delete to end of line
d0  Delete to start of line
dG  Delete to end of file
Cancel Edit Function
u  Undo last change
.  Do last change again
Copy and Insert Text
Y  Yank a copy
5Y  Yank a copy of 5 lines
p  Put below cursor
P  Put above cursor
Add/Append Text
a  Append after cursor
A  Append at line end
i  Insert before cursor
5i  Insert text 5 times
I  Insert at beginning of line
Add New Lines
o  Open a line below cursor
O  Open a line above cursor
Search Functions
n  Repeat previous search
N  Reverse previous search
Change Text
cw  Change a word
3cw  Change 3 words
C  Change line
r  Replace one character
R  Replace/type over a line
Command
Mode
Last
Line
Mode
Return Escape
: / ?
$ vi demo
i a o
Edit
Mode



评论暂缺

(Required)
(Required, will not be published)