"Maintainer: amix the lucky stiff " http://amix.dk- amix@amix.dk " "Version: 3.3 - 21/01/10 01:05:46 " "Blog_post: " http://amix.dk/blog/post/19486#The-ultimate-vim-configuration-vimrc "Syntax_highlighted: " http://amix.dk/vim/vimrc.html "Raw_version: " http://amix.dk/vim/vimrc.txt " "How_to_Install: " $ mkdir ~/.vim_runtime " $ svn co svn://orangoo.com/vim ~/.vim_runtime " $ cat ~/.vim_runtime/install.sh " $ sh ~/.vim_runtime/install.sh <system> " <sytem> can be `mac`, `linux` or `windows` " "How_to_Upgrade: " $ svn update ~/.vim_runtime " "Sections: " -> General " -> VIM user interface " -> Colors and Fonts " -> Files and backups " -> Text, tab and indent related " -> Visual mode related " -> Command mode related " -> Moving around, tabs and buffers " -> Statusline " -> Parenthesis/bracket expanding " -> General Abbrevs " -> Editing mappings " " -> Cope " -> Minibuffer plugin " -> Omni complete functions " -> Python section " -> JavaScript section " "Plugins_Included: " > minibufexpl.vim -http://www.vim.org/scripts/script.php?script_id=159 " Makes it easy to get an overview of buffers: " info -> :e ~/.vim_runtime/plugin/minibufexpl.vim " " > bufexplorer -http://www.vim.org/scripts/script.php?script_id=42 " Makes it easy to switch between buffers: " info -> :help bufExplorer " " > yankring.vim -http://www.vim.org/scripts/script.php?script_id=1234 " Emacs's killring, useful when using the clipboard: " info -> :help yankring " " > surround.vim -http://www.vim.org/scripts/script.php?script_id=1697 " Makes it easy to work with surrounding text: " info -> :help surround " " > snipMate.vim -http://www.vim.org/scripts/script.php?script_id=2540 " Snippets for many languages (similar to TextMate's): " info -> :help snipMate " " > fuzzyfinder -http://www.vim.org/scripts/script.php?script_id=1984 " Find files fast (similar to TextMate's feature): " info -> :help fuzzyfinder@en " "Revisions: " > 3.3: Added syntax highlighting for Mako mako.vim " > 3.2: Turned on python_highlight_all for better syntax " highlighting for Python " > 3.1: Added revisions ;) and bufexplorer.vim " """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => General """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Sets how many lines of history VIM has to remember sethistory=300
" Set to auto read when a file is changed from the outside setautoread
" With a map leader it's possible to do extra key combinations " like <leader>w saves the current file let mapleader ="," let g:mapleader =","
" Fast saving nmap<leader>w :w!<cr>
" Fast editing of the .vimrc map<leader>e :e! ~/.vim_runtime/vimrc<cr>
" When vimrc is edited, reload it autocmd!bufwritepost vimrc source ~/.vim_runtime/vimrc
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => VIM user interface """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Set 7 lines to the curors - when moving vertical.. setso=7
setwildmenu"Turn on WiLd menu
setruler"Always show current position
setcmdheight=2 "The commandbar height
sethid"Change buffer - without saving
" Set backspace config setbackspace=eol,start,indent setwhichwrap+=<,>,h,l
setignorecase"Ignore case when searching
sethlsearch"Highlight search things
setincsearch"Make search act like search in modern browsers
setmagic"Set magic on, for regular expressions
setshowmatch"Show matching bracets when text indicator is over them setmat=2 "How many tenths of a second to blink
" No sound on errors setnoerrorbells setnovisualbell sett_vb=
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Colors and Fonts """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" syntaxenable"Enable syntax hl
" Set font according to system ifMySys()=="mac" setgfn=Bitstream\ Vera\ Sans\ Mono:h13 setshell=/bin/bash elseifMySys()=="windows" setgfn=Bitstream\ Vera\ Sans\ Mono:h10 elseifMySys()=="linux" setgfn=Monospace\ 10 setshell=/bin/bash endif
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Files and backups """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Turn backup off, since most stuff is in SVN, git anyway... setnobackup setnowb setnoswapfile
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Text, tab and indent related """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" setexpandtab setshiftwidth=4 settabstop=4 setsmarttab
"""""""""""""""""""""""""""""" " => Visual mode related """""""""""""""""""""""""""""" " Really useful! " In visual mode when you press * or # to search for the current selection vnoremap<silent> * :call VisualSearch('f')<CR> vnoremap<silent> # :call VisualSearch('b')<CR>
" When you press gv you vimgrep after the selected text vnoremap<silent> gv :call VisualSearch('gv')<CR> map<leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Command mode related """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Smart mappings on the command line cno $h e ~/ cno $d e ~/Desktop/ cno $j e ./ cno $c e<C-\>eCurrentFileDir("e")<cr>
" $q is super useful when browsing on the command line cno $q <C-\>eDeleteTillSlash()<cr>
" Bash like keys for the command line cnoremap<C-A><Home> cnoremap<C-E><End> cnoremap<C-K><C-U>
cnoremap<C-P><Up> cnoremap<C-N><Down>
" Useful on some European keyboards map ½ $ imap ½ $ vmap ½ $ cmap ½ $
func! Cwd() let cwd =getcwd() return"e" . cwd endfunc
func! DeleteTillSlash() let g:cmd =getcmdline() ifMySys()=="linux"||MySys()=="mac" let g:cmd_edited =substitute(g:cmd,"\\(.*\[/\]\\).*","\\1","") else let g:cmd_edited =substitute(g:cmd,"\\(.*\[\\\\]\\).*","\\1","") endif if g:cmd == g:cmd_edited ifMySys()=="linux"||MySys()=="mac" let g:cmd_edited =substitute(g:cmd,"\\(.*\[/\]\\).*/","\\1","") else let g:cmd_edited =substitute(g:cmd,"\\(.*\[\\\\\]\\).*\[\\\\\]","\\1","") endif endif return g:cmd_edited endfunc
"Move a line of text using ALT+[jk] or Comamnd+[jk] on mac nmap<M-j> mz:m+<cr>`z nmap<M-k> mz:m-2<cr>`z vmap<M-j> :m'>+<cr>`<my`>mzgv`yo`z vmap<M-k> :m'<-2<cr>`>my`<mzgv`yo`z
"Delete trailing white space, useful for Python ;) func! DeleteTrailingWS() exe"normal mz" %s/\s\+$//ge exe"normal `z" endfunc autocmdBufWrite *.py :callDeleteTrailingWS()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Cope """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Do :help cope if you are unsure what cope is. It's super useful! map<leader>cc :botright cope<cr> map<leader>n :cn<cr> map<leader>p :cp<cr>
"""""""""""""""""""""""""""""" " => bufExplorer plugin """""""""""""""""""""""""""""" let g:bufExplorerDefaultHelp=0 let g:bufExplorerShowRelativePath=1
"""""""""""""""""""""""""""""" " => Minibuffer plugin """""""""""""""""""""""""""""" let g:miniBufExplModSelTarget =1 let g:miniBufExplorerMoreThanOne =2 let g:miniBufExplModSelTarget =0 let g:miniBufExplUseSingleClick =1 let g:miniBufExplMapWindowNavVim =1 let g:miniBufExplVSplit =25 let g:miniBufExplSplitBelow=1
"""""""""""""""""""""""""""""" " => Vim grep """""""""""""""""""""""""""""" let Grep_Skip_Dirs ='RCS CVS SCCS .svn generated' setgrepprg=/bin/grep\ -nH
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => MISC """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Remove the Windows ^M - when the encodings gets messed up noremap<Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm
"Quickly open a buffer for scripbble map<leader>q :e ~/buffer<cr>