" " V I M R C " " @updated: Mi 29 Jun 2012 " @revision: 3 set nocompatible " be iMproved " Vundle {{{ filetype off set rtp+=~/.vim/bundle/vundle/ call vundle#rc() " let Vundle manage Vundle Bundle 'gmarik/vundle' " Vundles " " github repos Bundle 'tpope/vim-fugitive' Bundle 'tpope/vim-rails' Bundle 'tpope/vim-haml' Bundle 'tpope/vim-endwise' Bundle 'tpope/vim-surround' Bundle 'tpope/vim-ragtag' Bundle 'tpope/vim-markdown' Bundle 'tpope/vim-unimpaired' Bundle 'scrooloose/nerdtree' Bundle 'msanders/snipmate.vim' Bundle 'ervandew/supertab' Bundle 'tomtom/tlib_vim' Bundle 'tomtom/tcomment_vim' Bundle 'tomtom/tselectbuffer_vim' Bundle 'tsaleh/vim-matchit' Bundle 'vim-scripts/taglist.vim' Bundle 'Townk/vim-autoclose' Bundle 'trapd00r/x11colors.vim' Bundle 'lilydjwg/colorizer' " Bundle 'fholgado/minibufexpl.vim' Bundle 'shemerey/vim-project' " Bundle 'Twinside/vim-codeoverview' " vim-scripts repos " non github repos " }}} " General settings {{{ filetype on filetype plugin indent on syntax on set title set mouse=a set shortmess=at " shorten error messages set nrformats+=alpha " in-/decrease letters with C-a/C-x set modeline " enable modelines set modelines=5 set number " enable line numbers set ruler " enable something set cursorline " enable hiliting of cursor line set backspace=2 " backspace over EOL etc. set background=dark " i prefer dark backgrounds set hidden " buffer switching should be quick set confirm " ask instead of just print errors set equalalways " make splits equal size set lazyredraw " don't redraw while executing macros set noshowmode " don't display mode, it's already in the status line let mapleader="," let maplocalleader="," " }}} " General Keybinds {{{ " Set MapLeader let mapleader = "," " Delete previous word with C-BS imap " Toggle Buffer Selection and list Tag Lists map :TSelectBuffer map :TlistToggle " Set text wrapping toggles nmap w :set invwrap:set wrap? " Set up retabbing on a source file nmap rr :1,$retab " cd to the directory containing the file in the buffer nmap cd :lcd %:h " Make the directory that contains the file in the current buffer. " This is useful when you edit a file in a directory that doesn't " (yet) exist nmap md :!mkdir -p %:p:h " Increase @revision # by 1 nmap incr /@updated wwwd$"=strftime("%a %d %b %Y") p/@revision $ " }}} " {{{ Window movement nmap :winc h nmap :winc j nmap :winc k nmap :winc l " }}} " GUI or no GUI, that's the question {{{ if has('gui_running') set guicursor+=a:blinkon0 " Cursor doesn't blink - it's annoying set guioptions-=m " No Menubar set guioptions-=T " No Toolbar set guioptions-=l " No Scrollbar left set guioptions-=L " No Scrollbar left when split set guioptions-=r " No Scrollbar right set guioptions-=r " No Scrollbar right when split set laststatus=2 " always show statusline " set gfn=Pragmata\ 6.5 set gfn=Neep\ Medium\ Semi-Condensed\ 9 " set gfn=Mensch\ 7 set lines=40 " Height set columns=85 " Width colorscheme nucolors else colorscheme xdefaults endif " }}} " Status line {{{ set laststatus=2 " always show statusline " Generic Statusline {{{ function! SetStatus() setl statusline+= \%1*\ %f \%H%M%R%W%7*\ ┃ \%2*\ %Y\ <<<\ %{&ff}%7*\ ┃ endfunction function! SetRightStatus() setl statusline+= \%5*\ %{StatusFileencoding()}%7*\ ┃ \%5*\ %{StatusBuffersize()}%7*\ ┃ \%=%<%7*\ ┃ \%5*\ %{StatusWrapON()} \%6*%{StatusWrapOFF()}\ %7*┃ \%5*\ %{StatusInvisiblesON()} \%6*%{StatusInvisiblesOFF()}\ %7*┃ \%5*\ %{StatusExpandtabON()} \%6*%{StatusExpandtabOFF()}\ %7*┃ \%5*\ w%{StatusTabstop()}\ %7*┃ \%3*\ %l,%c\ >>>\ %P \\ endfunction " }}} " Update when leaving Buffer {{{ function! SetStatusLeaveBuffer() setl statusline="" call SetStatus() endfunction au BufLeave * call SetStatusLeaveBuffer() " }}} " Update when switching mode {{{ function! SetStatusInsertMode(mode) setl statusline=%4* if a:mode == 'i' setl statusline+=\ Einfügen\ ◥ elseif a:mode == 'r' setl statusline+=\ Ersetzen\ ◥ elseif a:mode == 'normal' setl statusline+=\ \ ◥ endif call SetStatus() call SetRightStatus() endfunction au VimEnter * call SetStatusInsertMode('normal') au InsertEnter * call SetStatusInsertMode(v:insertmode) au InsertLeave * call SetStatusInsertMode('normal') au BufEnter * call SetStatusInsertMode('normal') " }}} " Some Functions shamelessly ripped and modified from Cream "fileencoding (three characters only) {{{ function! StatusFileencoding() if &fileencoding == "" if &encoding != "" return &encoding else return " -- " endif else return &fileencoding endif endfunc " }}} " &expandtab {{{ function! StatusExpandtabON() if &expandtab == 0 return "tabs" else return "" endif endfunction " function! StatusExpandtabOFF() if &expandtab == 0 return "" else return "tabs" endif endfunction " }}} " tabstop and softtabstop {{{ function! StatusTabstop() " show by Vim option, not Cream global (modelines) let str = "" . &tabstop " show softtabstop or shiftwidth if not equal tabstop if (&softtabstop && (&softtabstop != &tabstop)) \ || (&shiftwidth && (&shiftwidth != &tabstop)) if &softtabstop let str = str . ":sts" . &softtabstop endif if &shiftwidth != &tabstop let str = str . ":sw" . &shiftwidth endif endif return str endfunction " }}} " Buffer Size {{{ function! StatusBuffersize() let bufsize = line2byte(line("$") + 1) - 1 " prevent negative numbers (non-existant buffers) if bufsize < 0 let bufsize = 0 endif " add commas let remain = bufsize let bufsize = "" while strlen(remain) > 3 let bufsize = "," . strpart(remain, strlen(remain) - 3) . bufsize let remain = strpart(remain, 0, strlen(remain) - 3) endwhile let bufsize = remain . bufsize " too bad we can't use "¿" (nr2char(1068)) :) let char = "b" return bufsize . char endfunction " }}} " Show Invisibles {{{ function! StatusInvisiblesON() "if exists("g:LIST") && g:LIST == 1 if &list if &encoding == "latin1" return "¶" elseif &encoding == "utf-8" return "¶" else return "$" endif else return "" endif endfunction function! StatusInvisiblesOFF() "if exists("g:LIST") && g:LIST == 1 if &list return "" else if &encoding == "latin1" return "¶" elseif &encoding == "utf-8" return "¶" else return "$" endif endif endfunction " }}} " Wrap Enabled {{{ function! StatusWrapON() if &wrap return "wrap" else return "" endif endfunction function! StatusWrapOFF() if &wrap return "" else return "wrap" endif endfunction " }}} " }}} " Tabstops {{{ set tabstop=2 set shiftwidth=2 set softtabstop=2 set autoindent set smartindent set expandtab " }}} " Invisibles {{{ set listchars=tab:>\ ,eol:< set list nmap :set list! " }}} " Tabstops {{{ set tabstop=2 set shiftwidth=2 set softtabstop=2 set autoindent set smartindent set expandtab " }}} " Invisibles {{{ set listchars=tab:>\ ,eol:< set list nmap :set list! " }}} " Folds {{{ set foldmethod=marker set foldcolumn=1 " au BufWinLeave * mkview " au BufWinEnter * silent loadview " }}} " Pairings {{{ set showmatch " }}} " Margins {{{ set scrolloff=5 set sidescroll=5 " }}} " Search {{{ set incsearch set ignorecase " Toggle that stupid highlight search nmap ,n :set invhls:set hls? " }}} " Backup files {{{ set nobackup set nowb set noswapfile " }}} " Completion {{{ set wildmenu set wildmode=longest,full,list set ofu=syntaxcomplete#Complete " }}} " Snipmate {{{ imap =TriggerSnippet() " }}} " NERDTree {{{ map :NERDTreeToggle let NERDTreeChDirMode = 2 let NERDTreeShowBookmarks = 1 " }}} " Wrapping {{{ set linebreak set showbreak=↳\ " toggle wrapping nmap :let &wrap = !&wrap " }}} " RagTag {{{ imap o imap let g:ragtag_global_maps = 1 imap imap " }}} " 'Bubbling' {{{ nmap [e nmap ]e vmap [egv vmap ]egv " }}} " Formatting with Par (gqip) {{{ set formatprg=par\ -req nmap gqip " }}} " Pasting {{{ set paste nnoremap p ]p nnoremap p " }}} " Macros {{{ " Execute macro "q" with space nmap @q " Map @ to + for more comfortable macros on DE kb layout nmap + @ " }}}