" Flori's vimrc " General Settings "set autochdir "set wildmode=list:full set autoindent set autowrite set backspace=indent,eol,start if exists('&colorcolumn') set colorcolumn=79 end set textwidth=80 set dictionary=/usr/dict/words set nodigraph set encoding=utf8 set errorformat+=%f:%l set expandtab shiftwidth=2 tabstop=2 set foldcolumn=0 set formatoptions=cqrt set fsync set hidden set history=1000 set hlsearch set laststatus=2 set makeprg=errf set modelines=5 set mousehide set mouse=nv set nocindent set nocompatible set nocursorcolumn set nocursorline set nofoldenable set noignorecase set noincsearch set nojoinspaces set nopaste set nosmartcase set nosmartindent set nowrap set number set ruler set shortmess=atI set showcmd set showmatch set showmode set smarttab set statusline=%<%f%m%r%=%(%Bh=%bd%)@%(%l:%c\%)%4P set swapsync="fsync" set termencoding=utf8 set tildeop set title set ttyfast set viminfo='20,<50,s10,h,! set visualbell t_vb= set wildchar= set wildmenu set winminheight=0 if has("persistent_undo") set undofile if has("win32") || has("win64") set undodir=$TMP else set undodir=/tmp end end if has("win32") || has("win64") set directory=$TMP else set directory=/tmp end filetype on filetype indent on filetype plugin on source $VIMRUNTIME/macros/matchit.vim set t_Co=256 colorscheme flori " Configure GUIs if has("gui_running") set guipty hi Pmenu ctermbg=Grey guibg=DarkGrey set guioptions-=r set guioptions-=R set guioptions-=l set guioptions-=L if exists("+guioptions") set guioptions+=c end if has("gui_win32") set guifont=DejaVu\ Sans\ Mono:h12 "set antialias if exists("+guioptions") set guioptions-=T set guioptions-=m set guioptions+=p end elseif has("gui_gtk2") set guifont=DejaVu\ Sans\ Mono\ 12 if exists("+guioptions") set guioptions-=T set guioptions-=m set guioptions+=p end set guiheadroom=0 set columns=80 set lines=59 elseif has("gui_mac") || has("gui_macvim") set guifont=DejaVu\ Sans\ Mono:h14 if exists("+guioptions") set guioptions-=T set guioptions-=m set guioptions+=p end set antialias set guiheadroom=0 "set macatsui set columns=160 set lines=86 elseif has("x11") set guifont=-b&h-lucidatypewriter-*-*-normal-*-17-*-*-*-*-*-iso10646-* if exists("+guioptions") set guioptions-=T set guioptions-=m end end else hi DiffAdd ctermbg=green hi DiffChange ctermbg=blue hi DiffText ctermbg=gray hi DiffDelete ctermbg=red end " Syntax let ruby_operators=1 if has("syntax") syntax on end " Browsing if has("browse") let g:explVertical=0 " let g:explSplitRight=1 let g:explSplitBelow=0 " let g:explStartRight=0 let g:explStartBelow=1 let g:explDetailedList=1 let g:explDateFormat="%Y-%m-%d %H:%M:%S" " let g:explHideFiles='^\.,\.gz$,\.exe$,\.zip$' let g:explUseSeparators=1 " Use separator lines end let g:netrw_longlist=1 let g:netrw_use_noswf= 0 let g:netrw_hide=1 let g:netrw_list_hidee='\..*\.sw[pon]$' let g:rails_statusline=0 let g:LustyJugglerSuppressRubyWarning=1 " CScope if has("cscope") " set csprg=/usr/local/bin/cscope set cscopetagorder=0 set cscopetag set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB end set csverb end " Mappings let mapleader="," let maplocalleader="," " open another file in this files directory map e :e =substitute(expand("%:p:h") . "/", " ", "\\\\ ", "g") map t :tabe =substitute(expand("%:p:h") . "/", " ", "\\\\ ", "g") map s :split =substitute(expand("%:p:h") . "/", " ", "\\\\ ", "g") map c :cd =substitute(expand("%:p:h") . "/", " ", "\\\\ ", "g") map h :call Csymbolhash() map H :%call Csymbolhash() map C :call Ccamelunderscore() map f :!echo %\|pbcopy map n :new " Switch of search highlighting map :nohlsearch if has("fullscreen") set fuoptions=maxhorz,maxvert function! Cfullscreen() if &fullscreen == "1" set nofullscreen else set fullscreen end endfunction map :call Cfullscreen() if has("gui_mac") || has("gui_macvim") map :call Cfullscreen() end au GUIEnter * set fullscreen end function! Ctoggle() if &buftype == "quickfix" cclose else copen end endfunction nnoremap :call Ctoggle() " Switch Windows map j_ map ∆ j_ map k_ map ˚ k_ " Switch Buffers map :bn map ¬ :bn map :bp map ˙ :bp map = map ≠ = map + map ≥ + map - map ≤ - " Configure navigation keys noremap noremap noremap noremap noremap noremap noremap noremap noremap noremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap vnoremap < >gv " Marks nnoremap ' ` nnoremap ` ' if has("autocmd") " Auto Command - Hooks augroup gzip autocmd! autocmd BufReadPre,FileReadPre *.gz setl bin autocmd BufReadPost,FileReadPost *.gz '[,']!gzip -d autocmd BufReadPost,FileReadPost *.gz setl nobin autocmd BufReadPost,FileReadPost *.gz execute ":doautocmd BufReadPost " . expand("%:r") autocmd BufWritePost,FileWritePost *.gz !mv :r autocmd BufWritePost,FileWritePost *.gz !gzip :r autocmd FileAppendPre *.gz !gzip -d autocmd FileAppendPre *.gz !mv :r autocmd FileAppendPost *.gz !mv :r autocmd FileAppendPost *.gz !gzip :r augroup END augroup bzip2 autocmd! autocmd BufReadPre,FileReadPre *.bz2 setl bin autocmd BufReadPost,FileReadPost *.bz2 '[,']!bzip2 -d autocmd BufReadPost,FileReadPost *.bz2 setl nobin autocmd BufReadPost,FileReadPost *.bz2 execute ":doautocmd BufReadPost " . expand("%:r") autocmd BufWritePost,FileWritePost *.bz2 !mv :r autocmd BufWritePost,FileWritePost *.bz2 !bzip2 :r autocmd FileAppendPre *.bz2 !bz2ip -d autocmd FileAppendPre *.bz2 !mv :r autocmd FileAppendPost *.bz2 !mv :r autocmd FileAppendPost *.bz2 !bzip2 -d :r augroup END augroup tex autocmd! autocmd FileType tex map :!latex % autocmd FileType tex map :!dvips `echo %\|sed -e 's/tex/dvi/'` autocmd FileType tex map :!xdvi -s 0 `echo %\|sed -e 's/tex/dvi/'` & autocmd FileType tex map :!gv `echo %\|sed -e 's/tex/ps/'` & autocmd FileType tex map :!pdflatex % autocmd FileType tex map :!acroread `echo %\|sed -e 's/tex/pdf/'` augroup END augroup c autocmd! autocmd FileType c setl sw=4 ts=4 cinoptions= formatoptions=cqrol cindent autocmd FileType c map :make autocmd FileType c map :%!indent 2>/dev/null -kr -i 4 autocmd FileType c map :make clean autocmd FileType c map i/* a */ augroup END augroup pascal autocmd! autocmd FileType pascal setl et st=2 sw=2 autoindent autocmd FileType pascal map :!gpc -o `echo %\|sed -e 's/\.pas//'` % autocmd FileType pascal map i{ a } augroup END augroup perl autocmd! autocmd Filetype perl setl et sw=4 ts=4 autoindent autocmd FileType perl map :w:!perl -c % autocmd FileType perl map :w:!perl -Tc % autocmd FileType perl map :w:.!perl -lne '/^(sub\s+\S+\s*\([^)]*\))\s*\{/ and print "$1;"' % autocmd FileType perl map :w:%!perl -pe 's/(sub \w+ *)\(.*\) */$1/' autocmd FileType perl map i# autocmd FileType perl map :w:!perl -I lib -I cfg % augroup END augroup ruby autocmd! autocmd FileType ruby setl et sw=2 ts=2 autoindent keywordprg=ri\ --no-pager autocmd FileType ruby map :w:!RUBYOPT="$RUBYOPT -Iext:lib:test:tests" ruby -wc % autocmd FileType ruby map :w:!RUBYOPT="$RUBYOPT -Iext:lib:test:tests" ruby % \| ruby -S decolor autocmd FileType ruby map :w:!rcov -Iext:lib:test:tests % autocmd FileType ruby map i# autocmd FileType ruby map !xmp ruby autocmd FileType ruby nmap V autocmd FileType ruby imap a autocmd FileType ruby map :w:%!xmp ruby -Iext:lib -w autocmd FileType ruby map :w:%!RUBYOPT="" xmp /usr/local/ruby-1.9/bin/ruby -Iext:lib -w autocmd FileType ruby map :!exuberant-ctags 2>/dev/null -R . autocmd FileType ruby setl suffixesadd=.rb,.h,.c autocmd FileType ruby setl path+=lib/** autocmd FileType ruby setl path+=test/** autocmd FileType ruby setl path+=tests/** autocmd FileType ruby setl path+=spec/** augroup END augroup javascript autocmd! autocmd BufNewFile,BufRead *.json setl filetype=javascript autocmd FileType javascript setl et sw=2 ts=2 cindent augroup end augroup java autocmd! autocmd FileType java setl cindent et sw=4 ts=4 autocmd FileType java map :w:!javac -deprecation % autocmd FileType java map :w:!javac % autocmd FileType java map :!rm `echo %\|sed -e 's/java/class/'` autocmd FileType java map i// autocmd FileType java map :w:!astyle -j %:n % autocmd FileType java nnoremap :JavaBrowser autocmd FileType java let JavaBrowser_Ctags_Cmd = '/usr/bin/exuberant-ctags' autocmd FileType java let JavaBrowser_Sort_Type = "name" autocmd FileType java let JavaBrowser_Display_Prototype = 1 autocmd FileType java let JavaBrowser_Use_SingleClick = 0 augroup END augroup lisp autocmd! autocmd FileType lisp setl lisp autoindent augroup END augroup scheme autocmd! autocmd FileType scheme setl lisp autoindent augroup END augroup ocaml autocmd! autocmd FileType ocaml setl et sw=2 ts=2 autoindent augroup END augroup xml autocmd! autocmd BufNewFile,BufRead *.jsf,*.jsp,*.babel,*.konfetti,*.tag,*.tld setl filetype=xml autocmd FileType xml setl et sw=2 ts=2 autoindent autocmd FileType xml map :w:!tidy -xml -raw -e % autocmd FileType xml map :%!tidy -xml -raw -i 2>/dev/null augroup END augroup html autocmd! autocmd FileType xml setl et sw=2 ts=2 autoindent autocmd FileType html map :w:!tidy -e % autocmd FileType html map :%!tidy -wrap 72 -iu 2>/dev/null augroup END augroup html2 autocmd! autocmd BufReadPre,FileReadPre *.html.* map :w:!tidy -e % autocmd BufReadPre,FileReadPre *.html.* map :%!tidy -wrap 72 -iu 2>/dev/null autocmd BufReadPre,FileReadPre *.html.* so $VIMRUNTIME/syntax/html.vim augroup END augroup misc autocmd! autocmd BufWritePost ~/.vimrc so ~/.vimrc augroup END augroup mutt autocmd! autocmd BufNewFile,BufRead mutt-* setl textwidth=72 augroup END end function! Cfind(...) redraw if a:0 == 0 let args = [ expand( '') ] else let args = copy(a:000) end let args_string = join(map(copy(args), 'shellescape(v:val)'), ' ') echo 'Finding ' . args_string . '...' set grepformat=%f set grepprg=discover let @/=args[0] silent execute "silent gr -a 'a-zA-Z0-9' -c -i " . args_string copen redraw! endfunction function! Cgrep(...) redraw if a:0 == 0 let args = [ expand( '') ] else let args = copy(a:000) end let args_string = join(map(args, 'shellescape(v:val)'), ' ') echo 'Grepping ' . args_string . '...' set grepformat=%f:%l set grepprg=search set hlsearch let @/=args[0] silent execute "silent gr -c " . args_string copen redraw! endfunction function! Ctest(...) execute 'w' if a:0 == 0 let name = expand('') else let name = a:1 end execute 'make ' . expand('%') . ' ' . name endfunction function! Cclassify(...) if a:0 == 0 let args = [ expand( '') ] else let args = copy(a:000) end let output = system("classify -b " . join(map(copy(args), 'shellescape(v:val)'), ' ')) execute "normal a" . output endfunction function! CpathClassify(...) if a:0 == 0 let args = [ expand( '') ] else let args = copy(a:000) end let output = system("classify " . join(map(copy(args), 'shellescape(v:val)'), ' ')) execute "normal a" . output endfunction function! Cdeclassify(...) if a:0 == 0 let args = [ expand( '') ] else let args = copy(a:000) end let output = system("classify -s -d " . join(map(copy(args), 'shellescape(v:val)'), ' ')) execute "normal a" . output endfunction function! Ccamelunderscore(...) execute 'w' let name = expand('') let output = system('classify -t ' . name) execute "normal ciW" . output endfunction function! Csymbolhash() range execute join([ 'silent ', a:firstline, ',', a:lastline, 's/\([^:]\):\([^:=!', "'", '" ]\{1,\}\) *=>/\1\2:/g' ]) endfunction function! Ccreatetags() call system("bundle execute create_tags") endfunction function! PrintGivenRange() range echo "firstline ".a:firstline." lastline ".a:lastline " Do some more things endfunction command! -bar -nargs=1 OpenURL :!open command! -bar -nargs=* -complete=file Find call Cfind() command! -bar -nargs=* -complete=file Grep call Cgrep() command! -bar -nargs=* -complete=file Test call Ctest() command! -bar -nargs=* -complete=file Classify call Cclassify() command! -bar -nargs=* -complete=file PathClassify call CpathClassify() command! -bar -nargs=* -complete=file Declassify call Cdeclassify() command! Createtags call Ccreatetags() command! -range Symbolhash ,call Csymbolhash() command! -range PrintGivenRange ,call PrintGivenRange() function! Iexec(cmd) let output = system(a:cmd) execute "normal a" . output endfunction function! Itime(fmt) execute "normal a" . strftime(a:fmt) endfunction " Abbreviations iabclear iabbrev I_MFG Mit freundlichen Grüssen,Florian Frank iabbrev I_DATE :call Itime("%F") iabbrev I_DATETIME :call Itime("%F %T") iabbrev I_TIME :call Itime("%T") iabbrev I_CLASS :call Iexec("classify -b " . expand('%')) iabbrev I_KLASS :call Iexec("classify -b " . expand('%')) iabbrev I_MODULE :call Iexec("classify -b " . expand('%')) iabbrev I_PATH_KLASS :call Iexec("classify " . expand('%')) iabbrev I_ENCODE # encoding: utf-8