I won’t try to demonstrate why Vim is an excellent editor. But here are some features useful when programming.
commands | description |
---|---|
gg=G | indent file |
== | indent line |
=a{ | indent block |
u | undo |
| redo |
: | go line number |
| go end of file |
:cwin | print error messages if some |
:clist | print compiler messages |
:cn | move next error |
:cp | move previous error |
:tag | go tag |
| go tag (for windows |
| open new tab and go tag under cursor |
| go back from tag |
gd | make search with current word under the cursor |
m | put a mark name |
' | go the mark |
:mak | do make |
:mak clean all | do make clean all |
:ls | show current buffer |
:b[n] | go buffer number [n] |
:sp | split window and open |
| move window to left, down, up or right |
| go half page up |
| go half page down |
:diffsplit | diff current buffer & |
:diffupdate | update diff buffers |
:DirDiff | diff directory ( &) see DirDiff plugin |
F11 | run VimCommander - see VimCommander plugin |
:grep bonjour % | search bonjour on current buffer (put results in error buffer) |
:grepadd hello *.c | search hello in all *c file |
:cwin | show error buffer |
:cn | go next entry in the error buffer |
q | start record |
q | stop current record |
@ | repeat record |
@@ | repeat previous record |
:he | go help for |
zfap | create paragraphe fold |
zc | close fold |
zo | open fold |
zm | make fold |
zr | reduce fold |
zi | z more or z reduce |
:set foldmethod=indent | fold according to the file indentation |
:set foldlevel=3 | fold more than third indent |
:set foldcolumn=4 | show a margin with folding indications |
:stag | split window and go tag |
:tselect /config_* | show all tag references that match config_* in error buffer |
:vsplit functions | open buffer with the function list |
:set ignorecase | casse independant search |
:set smartcase | like ignorecase if the exression is lowercase |
| completion (insert mode) |
| completion (insert mode) |
:tabe | open file in a new tab |
:tabc | close current tab |
:tab | run |
gt | go next tab |
| go next tab |
| go previous tab |
:set makeprg=gmake | under windows, the Gnu Collection Compiler |
:map | shortcut (F9 == save all and 'make') |
:map | shortcut (F10 == save all and 'make clean all') |
:argdo %s/ | replace |
:cs find s | show |
:cs reset | reset cscope database connexion |
:cs show | show cscope database connexion |
# cscope -R
leave : Ctrl-D
launch vim
:cs add cscope.out
:cs kill 0
:!cscope -R
:cs add cscope.out
:cs show
example that update cscope database |