execute pathogen#infect() " Setup {{ filetype plugin on set nocompatible set shortmess+=filmnrxoOtT " }} " General Settings {{ scriptencoding utf-8 set foldmethod=manual set ai " Disable Ex Mode map Q " 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 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 autocmd BufNewFile,BufRead * setlocal formatoptions-=cro " Do not add comment leaders on new lines " }} " 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 {{ let g:nofrils_heavycomments=1 let g:nofrils_heavylinenumbers=1 set background=dark colorscheme nofrils-dark " }} " }} " 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', 'path_html': '~/Dropbox/Documents/vimwiki_html/', 'auto_export':'1'}, \] nnoremap wb :Vimwiki2HTMLBrowse let g:vimwiki_auto_checkbox = 1 function! VimwikiLinkHandler(link) let link = a:link if link =~# '^vfile:' let link = link[1:] else return 0 endif let link_infos = vimwiki#base#resolve_link(link) if link_infos.filename == '' echomsg 'Vimwiki Error: Unable to resolve link!' return 0 else exe 'e ' . fnameescape(link_infos.filename) return 1 endif endfunction nmap VimwikiDiaryPrevDay nmap VimwikiDiaryNextDay " }} " 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 " }} " Syntastic Settings {{ set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} set statusline+=%* let g:syntastic_always_populate_loc_list = 1 let g:syntastic_auto_loc_list = 1 let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 let g:syntastic_javascript_checkers = ['eslint'] let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck'] let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] } nmap st :SyntasticToggleMode nmap sc :SyntasticCheck " }} " Vimux {{ map vp :VimuxPromptCommand map vl :VimuxRunLastCommand map vi :VimuxInspectRunner map vz :VimuxZoomRunner " }} " }} " 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}( .*\|$) " }} " 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 " }} " Date/Time Shortcuts {{ nnoremap "=strftime("%Y-%m-%d")P" inoremap =strftime("%Y-%m-%d") nnoremap "=strftime("%H:%M:%S")P" inoremap strftime("%H:%M:%S") nnoremap "=strftime("%Y%m%dT%H%M")P" inoremap strftime("%Y%m%dT%H%M") " }}