首页 > Tools & Tips > Vim 快捷键

Vim 快捷键

2009年5月10日 Zhaoren 发表评论 阅读评论

All these stuff can be found in the manual. Put them here together to give me random review chance.

Some best resource about vim usage:
General tips
  • Ctrl-N: auto completion
  • Position the cursor on the name of the function in your file and type [I: Vim will show a list of all matches for the function name in included files.
Search & Replace

这里有篇介绍文章:VIM下,在文件及目录中查找字符串的方法 。例如: vimgrep /登录/g **/*.html

查找的结果会显示在 QuickList 列表中。对于Quicklist 的操纵,参考下面的文章 打造自己的VIM: QuickFix 編譯視窗 。 这篇文章还介绍了打造快捷键,因为我的Vim使用的版本比较多,而且直接切换到Qucik List然后使用行移动也很方便的,所以就不配置这些快捷键。 更详细的参考见官方手册 Quickfix 或者 :help quickfix

替换 

可以在 vim 中查看帮助 :help argdo

示例:

:args **/*.htm

:argdo %s/旧/新/ge  |  update

Move around quickly
  • Use % to jump from an open brace to its matching closing brace. Or from a "#if" to the matching "#endif". Actually, % can jump to many different matching items. It is very useful to check if () and {} constructs are balanced properly.
  • Use [{ to jump back to the "{" at the start of the current code block.
  • Use gd to jump from the use of a variable to its local declaration.
  • * command to search for other places
  • CTRL-], CTRL-t with ctags/cscope

整页翻页 ctrl-f ctrl-b
f就是forword b就是backward

翻半页
ctrl-d ctlr-u
d=down u=up

滚一行
ctrl-e ctrl-y

zz 让光标所杂的行居屏幕中央
zt 让光标所杂的行居屏幕最上一行 t=top
zb 让光标所杂的行居屏幕最下一行 b=bottom

Highlight and increment search set:
set hls is

Block Operation (Delete a column):
  • start mode with Ctrl-v
  • specify a motion, e.g. G (to the end of the file), or use up / down keys
  • for the selected block specify an action, e.g. ‘d’ for delete
Split Window

set splitright “put the new split window in the right)

(some content cited from The Vim/Cscope tutorial)

  • move between windows via ‘CTRL-W w’ (or CTRL-W arrow key, or CTRL-W h/j/k/l for left/up/down/right),
  • close a window via ‘CTRL-W c’ (or good old ‘:q’),
  • make the current window the only one via ‘CTRL-W o’,
  • split a window into two via ‘CTRL-W s’ (or ‘CTRL-W v’ for a vertical split),
  • open a file in a new window via ‘:spl[it] filename’,
  • close a window ‘CTRL-W c’
cscope & ctags

The most completed tutorial I got from Internet:
The Vim/Cscope tutorial

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay

Related posts:

  1. My Vimrc File
  2. Google搜索使用快捷键
  3. 转贴:华南虎照片造假论泛起是谁的悲哀
  4. My Ubuntu Installation log
  5. Maybe Another Choice for QQ?
分类: Tools & Tips 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.