" NERDTree, Pathogen " Tagbar http://majutsushi.github.com/tagbar/ " Gundo http://sjl.bitbucket.org/gundo.vim " https://github.com/vim-scripts/Gundo " When started as "evim", evim.vim will already have done these settings. if v:progname =~? "evim" finish endif " Use Vim settings, rather than Vi settings (much better!). " This must be first, because it changes other options as a side effect. set nocompatible " allow backspacing over everything in insert mode set backspace=indent,eol,start if has("vms") set nobackup " do not keep a backup file, use versions instead else set backup " keep a backup file endif set history=50 " keep 50 lines of command line history set ruler " show the cursor position all the time set showcmd " display incomplete commands set incsearch " do incremental searching " For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries " let &guioptions = substitute(&guioptions, "t", "", "g") " Don't use Ex mode, use Q for formatting map Q gq " CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, " so that you can undo CTRL-U after inserting a line break. inoremap u " In many terminal emulators the mouse works just fine, thus enable it. if has('mouse') set mouse=a endif " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif " Only do this part when compiled with support for autocommands. if has("autocmd") " Enable file type detection. " Use the default filetype settings, so that mail gets 'tw' set to 72, " 'cindent' is on in C files, etc. " Also load indent files, to automatically do language-dependent indenting. filetype plugin indent on " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx au! " For all text files set 'textwidth' to 78 characters. autocmd FileType text setlocal textwidth=78 " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). " Also don't do it when the mark is in the first line, that is the default " position when opening a file. autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif augroup END else set autoindent " always set autoindenting on endif " has("autocmd") " Convenient command to see the difference between the current buffer and the " file it was loaded from, thus the changes you made. " Only define it when not defined already. if !exists(":DiffOrig") command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis \ | wincmd p | diffthis endif set shiftwidth=2 tabstop=2 expandtab " set diffexpr=MyDiff() "function MyDiff() " let opt = '-a --binary ' " if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif " if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif " let arg1 = v:fname_in " if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif " let arg2 = v:fname_new " if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif " let arg3 = v:fname_out " if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif " let eq = '' " if $VIMRUNTIME =~ ' ' " if &sh =~ '\ ' . arg3 . eq " endfunction "===================================================================================== " KEYBINDINGS "===================================================================================== "GVIM nnoremap :if &go=~#'m'set go-=melseset go+=mendif nnoremap :if &go=~#'T'set go-=Telseset go+=Tendif nnoremap :if &go=~#'r'set go-=relseset go+=rendif "VIM "------------------------------------------------------------------------------- " some additional hot keys "------------------------------------------------------------------------------- " F2 - write file without confirmation " F3 - call file explorer Ex " F4 - show tag under curser in the preview window (tagfile must exist!) " F5 - open quickfix error window " F6 - close quickfix error window " F7 - display previous error " F8 - display next error "------------------------------------------------------------------------------- " nmap :TagbarToggle " mapping f9 to TagbarToggle nmap :NERDTreeToggle " mapping f10 to NERDTreeToggle nmap :NumbersToggle " mapping f11 to NumbersToggle noremap :GundoToggle " mapping f12 to Gundo map :write map :Explore nmap :exe ":ptag ".expand("") map :copen map :cclose map :cp map :cn " imap :write imap :Explore imap :exe ":ptag ".expand("") imap :copen imap :cclose imap :cp imap :cn " "------------------------------------------------------------------------------- " Fast switching between buffers " The current buffer will be saved before switching to the next one. " Choose :bprevious or :bnext "------------------------------------------------------------------------------- " map :if &modifiable && !&readonly && \ &modified :write :endif:bprevious imap :if &modifiable && !&readonly && \ &modified :write :endif:bprevious " "------------------------------------------------------------------------------- " Leave the editor with Ctrl-q : Write all changed buffers and exit Vim "------------------------------------------------------------------------------- nmap :wqa " "------------------------------------------------------------------------------- " comma always followed by a space "------------------------------------------------------------------------------- "inoremap , , " " "------------------------------------------------------------------------------- " autocomplete parenthesis, brackets and braces "------------------------------------------------------------------------------- "inoremap ( () "inoremap [ [] "inoremap { {} " vnoremap ( s()P% vnoremap [ s[]P% vnoremap { s{}P% " "------------------------------------------------------------------------------- " autocomplete quotes (visual and select mode) "------------------------------------------------------------------------------- xnoremap ' s''P xnoremap " s""P xnoremap ` s``P " "------------------------------------------------------------------------------- " Change the working directory to the directory containing the current file "------------------------------------------------------------------------------- if has("autocmd") autocmd BufEnter * :lchdir %:p:h endif " has("autocmd") " "=================================================================================== " VARIOUS PLUGIN CONFIGURATIONS "=================================================================================== " "------------------------------------------------------------------------------- " c.vim "------------------------------------------------------------------------------- " " --empty -- " "------------------------------------------------------------------------------- " taglist.vim : toggle the taglist window " taglist.vim : define the title texts for make " taglist.vim : define the title texts for qmake "------------------------------------------------------------------------------- noremap :Tlist inoremap :Tlist let Tlist_GainFocus_On_ToggleOpen = 1 let Tlist_Close_On_Select = 1 let tlist_make_settings = 'make;m:makros;t:targets' let tlist_qmake_settings = 'qmake;t:SystemVariables' if has("autocmd") " ---------- qmake : set filetype for *.pro ---------- autocmd BufNewFile,BufRead *.pro set filetype=qmake endif " has("autocmd") " " "------------------------------------------------------------------------------- " Leave the editor with Ctrl-q : Write all changed buffers and exit Vim "---------------------------------------------------------------------------------- nmap :wqa " " "Ctrl+C + Ctrl+V nmap "+gP imap vmap "+y call pathogen#infect() "---------------------------------------------------------------------------------- " Layout "---------------------------------------------------------------------------------- set number colorscheme vitamins highlight OverLength ctermbg=black ctermfg=white guibg=black match OverLength /\%85v.*/ "set textwidth=80 "set colorcolumn=80 " line to show 85 character mark "set colorcolumn=-2 "highlight ColorColumn ctermbg=black guibg=black