simple examples of how to

Thursday, October 20, 2011

[VIM] vim tips for developers

everything in the command mode unless noted

1) searching the matching bracket: at '{' or '}', type %

2) fast word searching: at the word that you want to find, type # or *

3) source code folding: at '{', type zf

4) source code unfolding: at folded line, type zo

5) auto indenting: select block by using v, and type =

6) auto completion (such as Eclipse): (in input mode) type some part of name and Ctrl+p or Ctrl+n

7) fast source code browsing with ctags:
- first, install ctags, (in ubuntu atp-get install ctags)
- then, go to the source code folder and type ctags -R *
- open the source code and move the cursor to the point that you want to find the declration and type Ctrl+]
- if you want to go back to previous, type Ctrl+t

8) partial visual-block selecting: Ctrl+v

9) Inserting to the partial-block: select partial block by using Ctrl+v and type Ctrl+I, then type anything and press 'Esc'

10) selecting previously selected block: gv

11) go to the previous line such as before searching: Ctrl+o
back & forth (Ctrl+o , Ctrl+i)

No comments:

Post a Comment