""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Maintainer: amix the lucky stiff " http://amix.dk - amix@amix.dk " " Version: 3.6 - 25/08/10 14:40:30 " " 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 " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => General """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " set nocompatible " explicitly get out of vi-compatible mode " Enable filetype plugin filetype plugin on filetype indent on set autoread " Set to auto read when a file is changed from the outside " set filetype set cpoptions=aABceFsmq " ||||||||| " ||||||||+-- When joining lines, leave the cursor between joined lines " |||||||+-- When a new match is created (showmatch) pause for .5 " ||||||+-- Set buffer options when entering the buffer " |||||+-- :write command updates current file name " ||||+-- Automatically add to the last line when using :@r " |||+-- Searching continues at the end of the match at the cursor position " ||+-- A backslash has no special meaning in mappings " |+-- :write updates alternative file name " +-- :read updates alternative file name syntax enable " syntax highlighting on syntax on " With a map leader it's possible to do extra key combinations " like w saves the current file let mapleader = "," let g:mapleader = "," " 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 " Fast saving nmap w :w! " Fast editing of the .vimrc map e :e! ~/.vim_runtime/vimrc " When vimrc is edited, reload it autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrc " set autochdir " always switch to the current file directory set backspace=indent,eol,start " make backspace a more flexible set nobackup " make no backup file set nowritebackup set clipboard+=unnamed " share windows clipboard set directory=/tmp " directory to place swap files in set fileformats=unix,dos,mac " support all three, in this order set hidden " you can change buffers without saving " (XXX: #VIM/tpope warns the line below could break things) set iskeyword+=_,$,@,%,# " none of these are word dividers set mouse=a " use mouse everywhere set noerrorbells " don't make noise set whichwrap=b,s,h,l,<,>,~,[,] " everything wraps " | | | | | | | | | " | | | | | | | | +-- "]" Insert and Replace " | | | | | | | +-- "[" Insert and Replace " | | | | | | +-- "~" Normal " | | | | | +-- Normal and Visual " | | | | +-- Normal and Visual " | | | +-- "l" Normal and Visual (not recommended) " | | +-- "h" Normal and Visual (not recommended) " | +-- Normal and Visual " +-- Normal and Visual set wildmenu " turn on command line completion wild style set wildignore=*.dll,*.o,*.obj,*.bak,*.exe,*.pyc " ignore these list file extensions set wildmode=list:longest " turn on wild mode huge list set history=1000 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => VIM user interface """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Set 7 lines to the curors - when moving vertical.. set so=7 set ruler "Always show current position set cmdheight=1 "The commandbar height set ignorecase "Ignore case when searching set magic "Set magic on, for regular expressions set showmatch "Show matching bracets when text indicator is over them set mat=2 "How many tenths of a second to blink " No sound on errors set noerrorbells set t_vb= set tm=500 set incsearch " BUT do highlight as you type you search phrase set laststatus=2 " always show the status line set lazyredraw " do not redraw while running macros set linespace=1 " insert 1 extra pixel line betweens rows " set list " we do what to show tabs, to ensure we get them out of my files " set listchars=tab:>-,trail:- " show tabs and trailing set matchtime=5 " how many tenths of a second to blink matching brackets for "set nohlsearch " do not highlight searched for phrases set hlsearch set wrapscan set nostartofline " leave my cursor where it was set novisualbell " don't blink " set number " turn on line numbers set numberwidth=5 " We are good up to 99999 lines set report=0 " tell us when anything is changed via :... set scrolloff=8 " Keep 8 lines (top/bottom) for scope set shortmess=aOstT " shortens messages to avoid 'press a key' prompt set showcmd " show the command being typed set showmatch " show matching brackets set sidescrolloff=10 " Keep 5 lines at the size set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v] " | | | | | | | | | | | " | | | | | | | | | | + current column " | | | | | | | | | +-- current line " | | | | | | | | +-- current % into file " | | | | | | | +-- current syntax in square brackets " | | | | | | +-- current fileformat " | | | | | +-- number of lines " | | | | +-- preview flag in square brackets " | | | +-- help flag in square brackets " | | +-- readonly flag in square brackets " | +-- rodified flag in square brackets " +-- full path to file in the buffer """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Colors and Fonts """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" syntax enable "Enable syntax hl " Set font according to system "#set gfn="DejaVu_Sans_Mono"\ 14 set gfn=DejaVu\ Sans\ Mono\ 16 set shell=/bin/bash if has("gui_running") set guioptions-=T set t_Co=256 set background=dark colorscheme pablo set nonu else colorscheme zellner set background=dark set nonu endif set encoding=utf8 try lang en_US catch endtry set ffs=unix,dos "Default file types """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Files, backups and undo """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Turn backup off, since most stuff is in SVN, git anyway... " set nobackup " set nowb " set noswapfile "Persistent undo try if MySys() == "windows" set undodir=C:\Windows\Temp else set undodir=~/.vim_runtime/undodir endif set undofile catch endtry """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Text, tab and indent related """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set expandtab set formatoptions=rq set shiftwidth=4 set tabstop=4 " set smarttab set shiftround " set lbr " set tw=120 set smartcase set wrap "Wrap lines " set autoindent " set smartindent """""""""""""""""""""""""""""" " => Visual mode related """""""""""""""""""""""""""""" " Really useful! " In visual mode when you press * or # to search for the current selection vnoremap * :call VisualSearch('f') vnoremap # :call VisualSearch('b') " When you press gv you vimgrep after the selected text vnoremap gv :call VisualSearch('gv') map g :vimgrep // **/*. function! CmdLine(str) exe "menu Foo.Bar :" . a:str emenu Foo.Bar unmenu Foo endfunction " From an idea by Michael Naumann function! VisualSearch(direction) range let l:saved_reg = @" execute "normal! vgvy" let l:pattern = escape(@", '\\/.*$^~[]') let l:pattern = substitute(l:pattern, "\n$", "", "") if a:direction == 'b' execute "normal ?" . l:pattern . "^M" elseif a:direction == 'gv' call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') elseif a:direction == 'f' execute "normal /" . l:pattern . "^M" endif let @/ = l:pattern let @" = l:saved_reg endfunction " TagList let Tlist_Show_One_File = 1 let Tlist_Exit_OnlyWindow = 1 "let Tlist_Show_Menu = 1 "let Tlist_Ctags_Cmd = 'C:\Utils\ctags.exe' nnoremap :TlistToggle " OmniCppCompletion set nocp map :! ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . let OmniCpp_GlobalScopeSearch = 1 let OmniCpp_NamespaceSearch = 1 let OmniCpp_DisplayMode = 0 let OmniCpp_ShowScopeInAbbr = 0 let OmniCpp_ShowPrototypeInAbbr = 1 let OmniCpp_ShowAccess = 1 let OmniCpp_DefaultNamespaces = [] let OmniCpp_MayCompleteDot = 1 let OmniCpp_MayCompleteArrow = 1 let OmniCpp_MayCompleteScope = 1 let OmniCpp_SelectFirstItem = 2 let OmniCpp_LocalSearchDecl = 0 " Visual Mark if &bg == "dark" highlight SignColor ctermfg=white ctermbg=blue guifg=wheat guibg=peru else highlight SignColor ctermbg=white ctermfg=blue guibg=grey guifg=RoyalBlue3 endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Command mode related """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Smart mappings on the command line cno $h e ~/ cno $d e ~/Desktop/ cno $j e ./ cno $c e eCurrentFileDir("e") " $q is super useful when browsing on the command line cno $q eDeleteTillSlash() " Bash like keys for the command line cnoremap cnoremap cnoremap cnoremap cnoremap func! Cwd() let cwd = getcwd() return "e " . cwd endfunc """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Moving around, tabs and buffers """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Map space to / (search) and c-space to ? (backgwards search) map / map ? map :noh " Smart way to move btw. windows map j map k map h map l " Close the current buffer map bd :Bclose " Close all the buffers map ba :1,300 bd! " Use the arrows to something usefull map :bn map :bp " Tab configuration " map tn :tabnew " map te :tabedit " map tc :tabclose " map tm :tabmove " When pressing cd switch to the directory of the open buffer map cd :cd %:p:h command! Bclose call BufcloseCloseIt() function! BufcloseCloseIt() let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") if buflisted(l:alternateBufNum) buffer # else bnext endif if bufnr("%") == l:currentBufNum new endif if buflisted(l:currentBufNum) execute("bdelete! ".l:currentBufNum) endif endfunction """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Cope """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Do :help cope if you are unsure what cope is. It's super useful! map cc :botright cope map n :cn map p :cp """""""""""""""""""""""""""""" " => bufExplorer plugin """""""""""""""""""""""""""""" let g:bufExplorerDefaultHelp=0 let g:bufExplorerShowRelativePath=1 map o :BufExplorer """""""""""""""""""""""""""""" " => Minibuffer plugin """""""""""""""""""""""""""""" " let g:miniBufExplModSelTarget = 1 " let g:miniBufExplorerMoreThanOne = 2 " let g:miniBufExplUseSingleClick = 1 " let g:miniBufExplMapWindowNavVim = 1 " let g:miniBufExplVSplit = 25 " let g:miniBufExplSplitBelow=1 " let g:bufExplorerSortBy = "name" " let g:miniBufExplMapWindowNavArrows = 1 " let g:miniBufExplMapCTabSwitchBufs = 1 " let g:miniBufExplModSelTarget = 1 autocmd BufRead,BufNew :call UMiniBufExplorer map u :TMiniBufExplorer """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Omni complete functions """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" autocmd FileType css set omnifunc=csscomplete#CompleteCSS """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Spell checking """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" "Pressing ,ss will toggle and untoggle spell checking map ss :setlocal spell! "Shortcuts using map sn ]s map sp [s map sa zg map s? z= """""""""""""""""""""""""""""" " => Python section """""""""""""""""""""""""""""" let python_highlight_all = 1 au FileType python syn keyword pythonDecorator True None False self au BufNewFile,BufRead *.jinja set syntax=htmljinja au BufNewFile,BufRead *.mako set ft=mako au FileType python inoremap $r return au FileType python inoremap $i import au FileType python inoremap $p print au FileType python inoremap $f #--- PH ----------------------------------------------FP2xi au FileType python map 1 /class au FileType python map 2 /def au FileType python map C ?class au FileType python map D ?def """""""""""""""""""""""""""""" " => JavaScript section """"""""""""""""""""""""""""""" au FileType javascript call JavaScriptFold() au FileType javascript setl fen au FileType javascript setl nocindent au FileType javascript imap AJS.log();hi au FileType javascript imap alert();hi au FileType javascript inoremap $r return au FileType javascript inoremap $f //--- PH ----------------------------------------------FP2xi function! JavaScriptFold() setl foldmethod=syntax setl foldlevelstart=1 syn region foldBraces start=/{/ end=/}/ transparent fold keepend extend function! FoldText() return substitute(getline(v:foldstart), '{.*', '{...}', '') endfunction setl foldtext=FoldText() endfunction """""""""""""""""""""""""""""" " => MRU plugin """""""""""""""""""""""""""""" let MRU_Max_Entries = 400 map f :MRU """""""""""""""""""""""""""""" " => Command-T """""""""""""""""""""""""""""" let g:CommandTMaxHeight = 15 set wildignore+=*.o,*.obj,.git,*.pyc noremap j :CommandT noremap y :CommandTFlush """""""""""""""""""""""""""""" " => Vim grep """""""""""""""""""""""""""""" let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated' set grepprg=/bin/grep\ -nH """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => MISC """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Remove the Windows ^M - when the encodings gets messed up noremap m mmHmt:%s///ge'tzt'm "Quickly open a buffer for scripbble map q :e ~/buffer au BufRead,BufNewFile ~/buffer iab xh1 =========================================== map pp :setlocal paste! map bb :cd .. " CTRL-X and SHIFT-Del are Cut vnoremap "+x vnoremap "+x " CTRL-C and CTRL-Insert are Copy vnoremap "+y vnoremap "+y " CTRL-V and SHIFT-Insert are Paste map "+gP map "+gP cmap + cmap + " Pasting blockwise and linewise selections is not possible in Insert and " Visual mode without the +virtualedit feature. They are pasted as if they " were characterwise instead. " Uses the paste.vim autoload script. exe 'inoremap