vi升级使用

3 篇文章 0 订阅

/******************************************************/
Name:Work logs

Author:Weigong Xu

Time:2013-10-29 10:39

Motto:
自信,勤奋,果敢,快乐勇敢的面对,积极乐观的生活!
因为成熟的人应该更多的关注自己的内在实力和才华,
应该以智慧、能力、才华、专业和气度去赢得成功和尊严!
/*****************************************************/
:w!
 can also be used to save edits in a file that was opened in read-only mode with
 vi -R or view(assuming you have write permission for file)
:w  
 You can also use :w to save the entire buffer (the copy of the file you are editing)
 under a new filename.(及另存为但是在拷贝的附件里面进行editing)
 such as:  :w practice.new
Saving Part of a File
 :230,$w newfile
 Save from line 230 to end of file in a new file
 :.,600w newfile
 Saves from the current line to 600 in a newfile
Appending to a Saved File(也就是将文档的两部分摘录出来拼成一个新的文件)
 We can use the Unix redirect and append operator(>>)with w to append all
 or part of contents of the buffer to an existing file.
 :1,10w newfile
 and then:
 :340,$w >>newfile
 now newfie would contain lines 1-10 and from line 340 to the end of the buffer.

Copying a  File into Another File
 :read filename 
 or its abbreviation
 :r filename
 the filename is the file you want to read to the curent file
 This command inserts the contents of filename starting on the line after the cursor
 position in the file.
 :187 r /home/tim/filename
 To read in the same file and place it after 187
 But how to read the filename from line 11 to line 124 to a the file.
 (There is a method that we can appending to save file then copy a file into another file)
 
 Here are other ways to read in a file:
 :$r /home/tim/data
  Place the read-in file at the end of the current file.
 :0r /home/tim/data
  Place the read-in file at the very beginning of the current file.
 :/pattern/r /home/tim/data
  Place the read-in file int the current file after the line containing pattern.
Editing Multiple Files
 vi file1 file2
 :n
 to calls in the next file(file2)
Using the Argument List
 When you open  two files such as file1 and file2.The first-named file ,file1
 ,appears on your screen.
 If you want to see all the filenames ,type as following:
 :args
 ??
 :rewind
Calling in New Files:(2 points)
 The following command is also useful.It discards your edits and returns to
 the last saved version of the current file:
 :e!
 Since % stands for the current filename , that line could also have been typed:
 :w %.new (% stands for yzyc.1030 which is the current file)
 
 Another way to move text from one file to another is to use the commands:ya
 and :pu(put).For example:
 :1,23ya a
 then you need to move with :n to the file where you want to put these lines
 Place the cursor on the line where you want to put the yanked lines.Then type
 :pu a
 to put the conents of buffer a after the current line.
 Note:this command must be used in mutile files.
 
CHAPTER 6
Global Replacement

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值