call pathogen#infect() " Setup {{ set nocompatible set shortmess+=filmnrxoOtT " }} " Plugins {{ " }} " General Settings {{ scriptencoding utf-8 " VimCrypt encryption method set cm=blowfish2 " Views, Backups, Swap, Info, and Undo files {{ set viminfo+=n~/.vim/viminfo set history=1000 set backup set undofile set undolevels=1000 set undoreload=10000 " Make directories for backups, swap, views, and undo " Also set appropriate settings to use those dirs function! InitializeDirectories() let base_dir = $HOME . '/.vim' let dir_list = { \ 'backups': 'backupdir', \ 'views': 'viewdir', \ 'swaps': 'directory', \ 'undos': 'undodir' } for [dirname, settingname] in items(dir_list) let directory = base_dir . '/' . dirname . '/' if exists("*mkdir") if !isdirectory(directory) call mkdir(directory) endif endif if !isdirectory(directory) echo "Warning: Unable to create directory: " . directory echo "Try: mkdir -p " . directory else let directory = substitute(directory, " ", "\\\\ ", "g") exec "set " . settingname . "=" . directory endif endfor endfunction call InitializeDirectories() " }} " }} " Text Formatting {{ function! SetTabWidth(width) exec "set shiftwidth=" . a:width exec "set tabstop=" . a:width exec "set softtabstop=" . a:width endfunction set expandtab " Tabs are spaces call SetTabWidth(2) " I use columns of 2 spaces set list set listchars=tab:\ \ ,trail:•,extends:#,nbsp:. " }} " Search {{ set incsearch " Find as you type set hlsearch " Highlight search terms set ignorecase " Case insensitive set smartcase " Case sensitive when uppercase chars are present " Hit backspace in normal mode to clear hlsearch nmap :nohlsearch " }} set number set norelativenumber set timeout ttimeoutlen=50 set mouse= " No mouse support set pastetoggle= " F12 to enable pastetoggle (sane indentation on pastes) set nospell " No spell checking " Disable bells set noerrorbells visualbell t_vb= if has('autocmd') autocmd GUIEnter * set visualbell t_vb= endif " Tabs and Buffers {{ set tabpagemax=15 " Only show 15 tabs set hidden " Allow buffer switching without saving " }} set cursorline " Highlight current line set backspace=indent,eol,start " Backspace for dummies set linespace=0 " No extra spaces between rows set winminheight=0 " Windows can be 0 lines high set wildmenu " Show list instead of just completing set wildmode=list:longest,full " Command completion, list matches, " then longest common part, then all set whichwrap= " Don't go to previous lines when going left/right set scrolljump=5 " Lines to scroll when cursor leaves screen set scrolloff=2 " Minimum lines to keep above/below cursor set nofoldenable " Don't auto-fold code set foldmethod=syntax " Fold based on syntax set nowrap " Don't wrap long lines set nojoinspaces " Prevents inserting two spaces after punctiuation on " a join (J) set splitright " Puts new vsplit windows to the right of current set splitbelow " Puts new split windows to the bottom of current set showmatch " Show matchign brackets/parens set matchpairs+=<:> " Match < and > with % set formatoptions+=j " Remove comment leaders when joining lines in comments " }} " Colors and UI {{ syntax on set colorcolumn=120 " Visual indicator on column 120 " Status line {{ set laststatus=2 " Always show status line set statusline=%f " Path to the file set statusline+=%< " If status line is too long, truncate here set statusline+=\ %y " File type, e.g. [go] set statusline+=%r " [RO] if read-only set statusline+=%m " [+] if modified set statusline+=%= " Switch to right side set statusline+=%p%% " % through file in lines set statusline+=\ %l,%c " Line, Col numbers set showmode " Show current mode below the status line on left side " (when not in normal mode) set showcmd " Show partial commands below the status line on the " right (and selected chars/lines in visual mode) " }} " Colorscheme {{ set background=dark colorscheme nofrils-dark let g:nofrils_heavycomments=1 let g:nofrils_heavylinenumbers=1 " }} " }} " Utility {{ " Vim REST Console {{ let g:vrc_trigger = 'r' " }} " Tagbar {{ nnoremap tt :TagbarToggle let g:tagbar_autofocus = 1 let g:tagbar_autoclose = 1 " }} " }} " Go {{ " Convenient mappings for all Go things au FileType go nmap r :GoRun! au FileType go nmap e (go-rename) au FileType go nmap s (go-implements) au FileType go nmap t :GoTest! au FileType go nmap c (go-coverage) au FileType go nmap v (go-vet) au FileType go nmap gd (go-doc) au FileType go nmap d :GoDef au FileType go nmap D :GoDescribe " Use `goimports` instead of `gofmt` let g:go_fmt_command = "goimports" " }} " Java {{ " let java_highlight_all=1 " let java_highlight_functions="style" " let java_allow_cpp_keywords=1 " }} " JSON {{ nmap jt :%!python -m json.tool:set filetype=json nmap jT :.!python -m json.tool:set filetype=json let g:vim_json_syntax_conceal = 0 " }} " Misc Things {{ " Vimwiki {{ let g:vimwiki_list = [{'path': '~/Dropbox/Documents/vimwiki/vimwiki', 'path_html': '~/Dropbox/Documents/vimwiki/vimwiki_html/', 'auto_export':'1'}] nnoremap wb :Vimwiki2HTMLBrowse let g:vimwiki_auto_checkbox = 1 " }} " Gist {{ let g:gist_detect_filetype = 1 let g:gist_open_browser_after_post = 1 let g:gist_post_private = 1 " }} " Scratch File {{ nmap sc :Scratch nmap cc :Sscratch " }} " Show syntax highlighting groups for word under cursor {{ " From http://stackoverflow.com/a/7893500/859353 nmap sn :call SynStack() function! SynStack() if !exists("*synstack") return endif echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') endfunc " }} " }} " Mappings and Macros {{ " expand_region {{ vmap v (expand_region_expand) vmap (expand_region_shrink) " }} " Code Folding Options {{ nmap f0 :set foldlevel=0 nmap f1 :set foldlevel=1 nmap f2 :set foldlevel=2 nmap f3 :set foldlevel=3 nmap f4 :set foldlevel=4 nmap f5 :set foldlevel=5 nmap f6 :set foldlevel=6 nmap f7 :set foldlevel=7 nmap f8 :set foldlevel=8 nmap f9 :set foldlevel=9 " }} " Find merge-conflict markers {{ map fc /\v^[<\|=>]{7}( .*\|$) " }} " Visual Shifting (Does not exit Visual mode) {{ vnoremap < >gv " }} " Allow the repeat operator on visual selsections {{ vnoremap . :normal . " }} " }} " Overrides {{ " Hook for local (user) changes if filereadable(expand("~/.vimrc.local")) source ~/.vimrc.local endif " Hook for local (directory) changes if filereadable(glob("./.vimrc.local")) source ./.vimrc.local endif " }}