Reference Links: VimFAQ : file:/home/thava/sun/learn/vim/vimfaq.html OR http://vimdoc.sourceforge.net/vimfaq.html VimTips : http://vim.wikia.com/wiki/Vim_Tips_Wiki VIMScripting Tutorial: http://www.swaroopch.com/notes/Vim_en:Scripting AMIX Vimrc: http://amix.dk/vim/vimrc.html My Tips: - Use :verbose set ts=4 - To output where it was last defined. - :perldo s/searchme/replaceme/g - Macro recording: qa (record macro a).....q; @a : Replay macro a. PHP Code Completion on VIM: http://stackoverflow.com/questions/1224838/vim-php-omni-completion Saving Folds in VIM: http://www.linux.com/archive/feature/114138 VIM Tip to configure "man currentword" : http://vim.wikia.com/wiki/PHP_online_help Colors config: http://tuxtraining.com/2009/07/28/how-to-have-a-lightweight-beautiful-functional-terminal Vim: Make sure following things are set correctly in vimrc : set tags=tags,./tags,../tags,../../tags The "./tags" file specifies the tag file to be there as in the same dir of the file. Hence you should specify "tags" if you want to take it from single parent dir. Autocompletion : This is default: set complete=.,w,b,u,t,i This helps in autocomplete when doing :tag func_name It also searches the current file contents when trying autocomplete. For inline autocomplete during editing using tags/cscope, omnifunc feature can be used by typing: Ctrl-x Ctrl-O : The feature is turned on by defaut from plugins in /usr/share/vim/vim71/autoload/*complete.vim plugins. You don't have to do anything to turn this on. The important files is ccomplete.vim (part of vim installation) Ctrl-P/Ctrl-N is usually to search the current file itself and do the complete based on local variables already declared. (where as Ctrl-X Ctrl-O uses ctags/cscope to complete) The code function prototype display autocomplete can be done by the plugin *code_complete.vim* (download from vim.org site) This will work only with exuberant ctags database generated from following command : ctags -R --c-kinds=+p --fields=+S --exclude="\.so" --exclude="install/*" ..... Just type my_func( this will display the prototype of the function. gd Go to the definition (or declaration) of the function or variable under the cursor. K Go to the man page for the word currently under the cursor. Ctrl-V : Visual Mode; Ctrl-V Ctrl-V - Visual Block Selection; Ctrl-End: To mark end of block; x - Cut; Ctrl-v+P: put in block mode V : Visual mode http://dancingpenguinsoflight.com/2009/05/more-efficient-html-editing-in-vim/ Close Tags: http://www.vim.org/scripts/script.php?script_id=13 Better colors for syntax highlighting: http://vim.wikia.com/wiki/Better_colors_for_syntax_highlighting configuring the colours isn't too hard. as root head over to /usr/share/vim/vim63/colors/ See evening.vim (example) eg: (my evening.vim file has the added line) hi Comment ctermfg=DarkGrey guifg=DarkGrey you can then do the same things for Constant and Identifier types. You'll notice what you're looking for in the syntax definition files. /usr/share/vim/vim63/syntax for me. To change the search highlighting I use: hi Search guibg=LightBlue highlight ErrorMsg guibg=White guifg=Red "hi Search guibg=LightBlue" is only for the GUI version of Vim. If you're using Vim in-console, try "hi Search ctermbg=LightBlue" Good color schemes: :source /usr/share/vim/vim71/colors/slate.vim Following will choose color name: let colors_name = "default" let colors_name = "slate" let colors_name = "peachpuff" Retrieved from "http://vim.wikia.com/wiki/Better_colors_for_syntax_highlighting" To convert source to html with highlighting do any one of: :runtime! syntax/2html.vim :TOhtml :10,40TOhtml Is folding possible!!! baan.vim let baan_fold=1 If you want to use folding in your C files, you can add these lines in a file an the "after" directory in 'runtimepath'. For Unix this would be ~/.vim/after/syntax/c.vim. syn sync fromstart set foldmethod=syntax set foldminlines=5 set foldnestmax=6 zf5j -- Create fold for next 5 lines. zo -- Open fold; zO - open fold recursively zc -- Close fold; zC - Close fold recursively zM - Fold everything zR - Unfold everything za - Toggle code folding (for everything) Another folding setting: "folding settings set foldmethod=indent "fold based on indent set foldnestmax=10 "deepest fold is 10 levels set nofoldenable "dont fold by default set foldlevel=1 "this is just what i use Ctrl-W : Switch between windows. :sp filename : New view port of same file. Note: DiffChange color highlighting is pathetic. Following are solid background alternatives which are pleasing: ErrorMsg cterm=bold ctermfg=7 ctermbg=1 guifg=White guibg=Red MatchParen term=reverse ctermbg=6 guibg=Cyan ctermbg = 1 Brown; 2 - Green ; 4 blue; 5 - magenta; 6 - Teal; 7 - lightgrey; *cterm-colors* Stick to only these colors: 1 - Brown; 6 - Teal; 7 - Lightgrey; Black 0; DarkGrey - 8 Brown 1,4 LightRed - 9 Green 2 LightGreen - 10 DarkBlue 5 Yellow - 11 Teal 6 LightBlue - 14 Grey 7 White - 15 VIMScripting ------------ When you write vim scripts, use this: is the current word! Examples: function ThavaPhpHelp() :!firefox "http://php.net/manual/en/function..php" endfunction function ThavaNext() execute "/" . expand("") endfunction nmap qp :call ThavaPhpHelp() nmap qn :call ThavaNext() Note: execute "replays" the argument to vim input. :! executes system command Examples: :let len = strlen(getline(".")) Functions Available: :echo CurrentLineLength() :if has("gui_running") : colorscheme desert :else : colorscheme darkblue :endif :let i = 0 :while i < 5 : echo i : let i += 1 :endwhile :let fruits = ['apple', 'mango', 'coconut'] :echo fruits[0] " apple :echo len(fruits) " 3 :call remove(fruits, 0) :echo fruits " ['mango', 'coconut'] :call sort(fruits) :echo fruits " ['coconut', 'mango'] :for fruit in fruits : echo "I like" fruit :endfor " I like coconut " I like mango if exists("loaded_capitalize") finish endif noremap