Vim tips
divide window
[Ctrl] + w v => split vertically.
[Ctrl] + w s => split horizontally.
:vs filename => split vertically and open file.
:sp filename => split horizontally and ope file.
:qa close all windows.
(in shell) vim -o txt.a txt.b => open txt.a and txt.b in two windows split horizontally.
(in shell) vim -O txt.a txt.b => open txt.a and txt.b in two windows split vertically.
- tab
:tabnew filename => open file in a new tab.
[Ctrl] + [Page Up/Down] => move to the other tab.
:tabn => go to next tab.
:tabp => go to previous tab.
(in shell) vim -p txt.a txt.b txt.c => open txt.a, txt.b, and txt.c in three respective tabs.
- go to file
gf => go to file under the cursor.
[Ctrl] + ^ => go back to the previous file.
:find filename => find and go to the file.
:tabf filename => find and open the file in a new tab.
Plug-ins
Auto Close(link): Insert parentheses automatically.
- Install: Download autoclose.vim from web site and save into ~/.vim/plugin directory.
- Install: Download autoclose.vim from web site and save into ~/.vim/plugin directory.
NERD commenter(link): Toggle comment.
Install: Download file, unzip and move it to ~/.vim directory(~/.vim/doc and ~/.vim/plugin).
Usage:
Select lines with visual block
[] + c + [Space] : Toggle comment.
[] + c + [a] : Change comment style (e.g. «/* */» <-> «//»)