免费注册 查看新帖 |

Chinaunix

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

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

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-05-25 20:43 |只看该作者 |倒序浏览

Starting and Ending VI
Starting VI
vi filename
Edits filename
vi -r filename
Edits last save version of filename after a crash
vi + n filename
Edits filename and places curser at line n
vi + filename
Edits filename and places curser on last line
vi +/string filename
Edits filename and places curser on first occurance of string
vi filename file2 ...
Edits filename, then edits file2 ... After the save, use :n

注:
1.最常用的编辑
2.当vi程序出错时,文件出错时很有用
3.编辑文件直接定位到N行,可以配合:set nu查看文件行号
4.编辑文件直接定位到最后一行
5.编辑文件并把光标直接定位到与当前字符匹配的行,这样的组合看上去太炫了。
6.编辑多文件,在Basic part提到了切换文件时可以输入:e filename 或用:n ,:p

Status
:.=
Shows current line number
:=
Shows number of lines in file
Control-G
Shows filename, current line number, total lines in file, and % of file location
l
Displays tab (^l) backslash (\) backspace (^H) newline ($) bell (^G) formfeed (^L^) of current line

Ranges
:n,m
Range - Lines n-m
:.
Range - Current line
:$
Range - Last line
:'c
Range - Marker c
:%
Range - All lines in file
:g/pattern/
Range - All lines that contain pattern

Shell Functions
:! cmd
Executes shell command cmd; you can add these special characters to indicate:% name of current file# name of last file edited
!! cmd
Executes shell command cmd, places output in file starting at current line
:!!
Executes last shell command
:r! cmd
Reads and inserts output from cmd
:f file
Renames current file to file (实验没通过,不知道是不是因为OS的原因)
:w !cmd
Sends currently edited file to cmd as standard input and execute cmd
:cd dir
Changes current working directory to dir
:sh
Starts a sub-shell (CTRL-d returns to editor)
!}sort
Sorts from current position to end of paragraph and replaces text with sorted text

注:
:sh 和 :!cmd有异曲同工之妙,我更喜欢:sh ,给人一种干净的界面
!}sort 是用来文本内容排序的


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/26090/showart_309812.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP