首页 > 代码库 > linux----vi

linux----vi

vi------http://www.cs.colostate.edu/helpdocs/vi.html

查找: 

 /string search forward for occurrence of string in text
 ?string search backward for occurrence of string in text
 n move to next occurrence of search string
 N move to next occurrence of search string in opposite direction

退出:  

 

 :r filename<Return> read file named filename and insert after current line
(the line with cursor)
  :w<Return> write current contents to file named in original vi call
  :w newfile<Return> write current contents to a new file named newfile
  :12,35w smallfile<Return> write the contents of the lines numbered 12 through 35 to a new file named smallfile
  :w! prevfile<Return> write current contents over a pre-existing file named prevfile
 :x<Return> quit vi, writing out modified file to file named in original invocation
 :wq<Return> quit vi, writing out modified file to file named in original invocation
 :q<Return> quit (or exit) vi
 :q!<Return> quit vi even though latest changes have not been saved for this vi call

删除

*

 

 x delete single character under cursor
 Nx delete N characters, starting with character under cursor
 dw delete the single word beginning with character under cursor
 dNw delete N words beginning with character under cursor;
  e.g., d5w deletes 5 words
  D delete the remainder of the line, starting with current cursor position
* dd delete entire current line
  Ndd or dNd delete N lines, beginning with the current line;
  e.g., 5dd deletes 5 lines

复制粘贴:

 yy copy (yank, cut) the current line into the buffer
 Nyy or yNy copy (yank, cut) the next N lines, including the current line, into the buffer
 p put (paste) the line(s) in the buffer into the text after the current line

linux----vi