VI 常用命令
:%s/abcd/efg/g 查找所有abcd并替换为efg:n,d 删除从第n行到当前行的内容
:m,nd 删除第m到第n行
0 Move to beginning of current line
$ Move to end of current line
]]Move to end of file
[[ Move to beginning of file
n+方向键 往指定方向移动n字符或者移动n行
^ 代表Ctrl键
^f PageDown
^b PageUp
- Move to the beginning of last line
+ Move to the beginning of next line
M Move to center line of current page
fx Move forword to 'x' in current line
d$ Delete to end of current line
d0 From beginning delete to current cursor
0,$d 删除所有内容
要退出:模式,按^c
如 :10,20d 若不想执行该命令(删除10至20行)则按^c退出
最常用set命令
set nowrapscan 搜索到文件末尾停止
set nu Show line number
set nonu Unshow line number
set tab=n Set table width n spaces
set ai Set autoindent
set noai Cancel autoindent
set all Get brief help of set
yy Copy current line
nyy Copy n lines (从当前行往下数)
y$ Copy to end of line
y0 From beginning of current line copy to cursor
:20,30y 复制第20到第30行之间的内容
p paste after current cursor or current line
J Link following line to current line (将下一行合并到当前行)
u undo last modify
o Make a new line after current line
:n 编辑下一个文件
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9044178/viewspace-1458689/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/9044178/viewspace-1458689/