- 论坛徽章:
- 0
|
接触VI已经两年了,还没有像今天这样感觉到VI竟如此强大,不由的佩服得五体投地,真是一个不能再出色的经典作品。闲话少扯,开始正题。
注:本文所涉及的实验均来自于Solaris 10,可能和LINUX间存在些差异。
Quitting
:x
Exit, saving changes
ZZ
Exit and save changes if any have been made按Esc后直接输入大写字母,不用输入符号: 我之前也犯类似错误
Inserting Text
i
Insert before cursor
I
Insert before line
a
Append after cursor
A
Append after line
o
Open a new line after current line
O
Open a new line before current line
r
Replace one character
R
Replace many characters
Deleting text
Almost all deletion commands are performed by typing d followed by a motion. For example, dw deletes a word. A few other deletes are:
x
Delete character to the right of cursor
X
Delete character to the left of cursor
D
Delete to the end of the line
dd
Delete current line
:d
Delete current line
Changing text
The change command is a deletion command that leaves the editor in insert mode. It is performed by typing c followed by a motion. For wxample cw changes a word. A few other change commands are:
C
Change to the end of the line
cc
Change the whole line
Files
:w file
Write to file
:r file
Read file in after line
:n
Go to next file
:p
Go to previos file
:e file
Edit file
!!program
Replace line with output from program
注:
1.相当于另存
2.要想迅速创建文件时,又不想输入,此时你可以用复制,或>等方法,但更好的是用:w file 如:w /etc/passwd 此文件比较规则,便于实验
3.同时edit 多个文件时,跳到下一个文件
4.同时edit 多个文件时,跳到上一个文件,这个我试了不行,倒是下面这条命令来得直接,
5.执行外部命令,其输出作为当前行的输入
Other
~
Toggle upp and lower case
J
Join lines
.
Repeat last text-changing command
u
Undo last change
U
Undo all changes to line
注:
1.~就是把大小写颠倒
2.J是把上下两行联成一行
3.重复执行最后的命令,尤其是重复粘贴时
4.撤消最后一条命令
5.撤消所有操作,这个可比Word强多了,Word中撤消次数有限
:n,mw newfile
Range - Lines n-m
:n,mw >>file
Saves lines n through m to the end of file
1.把当前文件的n至m行另存为新文件
2.把当前文件的n至m行追加到某文件
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/26090/showart_309802.html |
|