免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1116 | 回复: 0
打印 上一主题 下一主题

体验VI的强大功能-Basic part [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-25 20:24 |只看该作者 |倒序浏览
接触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
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP