Vim Key

来源:互联网 发布:js延迟加载 编辑:程序博客网 时间:2024/05/16 04:59

1.Cursur movement:
 h j k l  left down up right
 0 $  0 the start of line $ the end of line
 G  the end of file
 gg   the start of file


2.search and replace
 /word   downward search
 ?word  forward search
 n  next
 N  reverse direction next
 :n1,n2s/word1/word2/g replace word1 with word2 from n1 to n2
 :n1,n2s/word2/word2/gc same as before except with check


3.delete,copy and paste
 x X   delete one character
 dd   delete one line
 yy  yank
 p  paste
 :n1,n2y  yank the content from n1 to n2


4.undo and redo
 u  undo
 Ctrl+r  redo
5.switch mode
 i I o O a A switch into edit mode
 Esc  back to general mode


6.command line mode
 :wq  save and quit
 :q!  quit without any tip
 :e!  roll back to the original state
 :! command  execute command
 :n  go to the nth line
 :set nu  set number
 :set nonu set nonumber
 :w filename  save as


7.multi windows
 :sp [filename] split current window
 :vs [filename]  vertical split current window
 :Ctrl+w+j next window
 :Ctrl+w+k previous window


8.multi files
 $vi file1,file2,file3...
 :n  next file
 :N  privious file
 :files   file list


9.block selection
 v  charactor selection
 V  line selection
 Ctrl+v  block selection
 y  yank current selection
 d  delete current selection

原创粉丝点击