Sunday, November 16, 2008

My VIM Tips

File Open/Create:
  • :e create/open a new file
  • :w write file to disk
  • :q quit the window
  • :q! quit without saving
Editing:
  • o: Start writing on line below cursor
  • O: Start writing on line above cursor
  • A: Append character at end of line.
  • s: substitute the character on cursor with new one.

Copy/Paste:
  • yy : copy a line
  • p: paste line below cursor
  • P:paste line on cursor
Search highlight:
Turn off search highlight. Its very annoying when you search something and every search gets highlighted. You can easily turn off that search by '_' key.
nnoremap _ :nohl


Auto Completion
  • Ctrl-n : for auto completion for words already entered in file.
Project Plugin:
  • :let g:proj_flags="imstTvcg" (Add this line to vimrc file)
  • zo,zc Folds and unfolds the folder
  • zO,zC apply folding and unfolding recursiverly
  • \C Create Project
  • Space toggle width of project pane
  • \G search in project
  • F12 : toggle project window
  • \r,\R refreshes the project folder no-recursive and recursively respectively.
  • \I Complete file path of file on cursor on status line.
CTags:
Install ctags
Install taglist plugin
Set in vimrc:
let g:ctags_path='/usr/bin/local/ctags'
let g:ctags_statusline=1
let g:generate_tags =1
nnoremap :Tlist

Abbrevations:
Add following to vimrc:

iab intmain intmain(int argc, char *argv[]){return 0;}
iab #i #include
iab #d #define


Buffer navigation:
map :bprevious
map :bnext
map :bfirst
map :blast

No comments: