这4天接连使用vim编辑器,发现vim是自己的编写代码的效率提高很多
虽然没有自动补全的功能,但是在插入,复制,删除方面带来了巨大的提高。
下面我来做一下简单的vim编辑器快捷建的使用。
建议可以才console prompt 中键入 vimtutor 在这个文本中练习vim快捷键的使用。
下面是我对vim 快捷键的总结。
(1)h,j,k,l represent left,down,up,right separately.
(2)type x means delet one unwanted character.
(3)type A means append after the line.
(4)use dw to delete a word.
(5)type d$ to delete to the end of the line.
(6)type 2w to move the cursor two words forwards.
(7)type 3e to move the cursor to the end of the third word forward.
(8)type 0 to move to the start of the line.
(9)type dd to delete a whole line and 2dd can delete two lines.
(10)press u to undo the last command. U can fix a whole line.
(11)CTRL-R can redo the commands.
(12)type cw to delete a word and type c$ to delete to the end of the line.
(13)CTRL-G will show you the filename and the postion in the file.
(14)G will help you move to the bottom of the file.
(15)gg will help you move to the start of the file.
(16)type the number of the line you were on and then G. This will return you to the line you were on when you first pressed CTRL-G.
(17)type rx to replace the character at the cursor with x.
(18)to change until the end of the word, type ce. notice that ce delets the word and place you in insert mode.
********************************************************************************************************
the search command.
(1)type / followed by
(2)to search for the same phrase again,simply type n
(3)to search for the same phrase in the opposite direction, type N.
(4)to search for a phrase in the backward direction, use ? instead of /.
(5)type % to find a matching ),],or}. this is very useful in debugging a program with unmatched parentheses.
THE SUBSTITUTE COMMAND
(1) type: s/old/new/g to substitue 'new' for 'old'. //用 new 来替代 old
(2)type: s/old/new to change the first occurance of "old" in the line.
(3) change every occurance of a character string between two lines.
type :#,#s/old/new/g where #,# are the line numbers of the range of lines
where the subsitution is to be done.
(4)type : %s/old/new/g to change every occurance in the whole file.
(5)type : %s/old/new/gc to find evey occurance in the whole file, with a prompt
whether to substitute or not.
HOW TO EXECUTE AN EXTERNAL COMMAND
Under the normal mode, type :! followed by an external command to execute that
command.
(1) :W FILENAME help you write the content to the FILENAME.
(2) type V help you enter to the VISUAL mode. and then use '<,'>W TEST to
write this to the file.
(3)retrieve the TEST file using the command : r TEST where TEST is the name
of the file you used. the file you retrieve is placed below the cursor line.
(4)type the lowercase letter o to open up a line BELOW the cursor and place
you in Insert mode. Open up a line above this by typing 0 while the cursor is
on this line.
(5)e help the cursor jump to the neighbour word and type a hlep you to append
text after the cursor.
(6) press R help you enter the REPLACE mode.
本文分享了作者连续四天使用Vim编辑器的心得体会,并总结了一系列实用的Vim快捷键,包括移动、删除、替换等基本操作及搜索、替换等高级功能,帮助读者提高代码编写效率。

被折叠的 条评论
为什么被折叠?



