coreBugZJ

此 blog 已弃。

Vim学习笔记 (转)


1. Type 0 (zero) to move to the start of the line.
Type 2w to move the cursor two words forward.
Type 3e to move the cursor to the end of the third word forward.

2. Type x to delete the first unwanted character.
Type rx to replace the character at the cursor with x

3. To change until the end of a word, type ce (ce + 修正的单词)

4. C就类似于d。de,dw,d$都对应着ce,cw,c$

5. Type CTRL-G to show your location in the file and the file status.
Type G to move to a line in the file.

6. Press G to move you to the bottom of the file.
Type gg to move you to the start of the file.

7. Type / followed by a phrase to search for the phrase.

8. To search for the same phrase again, simply type n .
To search for the same phrase in the opposite direction, type N

9. To search for a phrase in the backward direction, use ? instead of /

10. To go back to where you came from press CTRL-O

11. 匹配使用%,放置在一个括号下面,然后输入%,就会跳转到另外一个上面。

12. type :#,#s/old/new/g where #,# are the line numbers of the range
of lines where the substitution is to be done. (两行之间的所有文本)
Type :%s/old/new/g to change every occurrence in the whole file.(不提示,但是是整个文件)
Type :%s/old/new/gc to find every occurrence in the whole file,
with a prompt whether to substitute or not.(提示是否代替)

13.g表示取代该行所有的。
比如:s/thee/the/g表示取代该行中所有的thee为the。

14. CTRL-G displays your location in the file and the file status.
G moves to the end of the file.
number G moves to that line number.
gg moves to the first line.

15. :! 运行执行外部程序。(冒号是必须的,命令模式都必须的,比如:w表示保存) (外部命令如ls,pwd需要使用!,而内部命令则是直接:w等等,不需要使用!)

16. 输入v进入视觉模式,此时鼠标向下会选中部分文字,然后可以对选中的文字操作。
比如:w TEST则会把选中的保存位文本。
:d则会删除选中的文本。

17. 插入一个文件的部分内容,使用:r FILENAME即可插入一个文件到该行。

18. 在下方新建一个空行,使用o,
在上方新建一个空行,使用O。(命令模式下) (输入命令后会进入插入模式)

NOTE: a, i and A all go to the same Insert mode, the only difference is where
the characters are inserted.(a是在光标后,A是在行末尾,i则是光标处)

19. e跳转一个单词。e.g: 2e表示跳转两个单词,比向右键更快捷。
G跳转行。e.g: 721G表示跳转到第721行

20. 替换:
R:替换位多个字母
r:替换位单个字母

21. Move the cursor to the end of the next line: j$

22. Use the y operator to copy text and p to paste it

NOTE: you can also use y as an operator; yw yanks one word.

23. Set the 'ic' (Ignore case) option by entering: :set ic(包含大小写匹配的都显示出来,比如Ignore,IGNORE)
Set the 'hlsearch' and 'incsearch' options: :set hls is(高亮显示)

(set option)
24. Typing ":set xxx" sets the option "xxx". Some options are:
'ic' 'ignorecase' ignore upper/lower case when searching
'is' 'incsearch' show partial matches for a search phrase
'hls' 'hlsearch' highlight all matching phrases
You can either use the long or the short option name.

25. Prepend "no" to switch an option off: :set noic

26. 在命令模式下,输入e然后按TAB键,会自动出现很多相关的命令(以e开头的命令)。(第一个相关的)
按Ctrl + D能够出现所有以他开头的命令。

posted on 2011-10-09 14:09 coreBugZJ 阅读(228) 评论(0)  编辑 收藏 引用 所属分类: LinuxEditor


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理