" load system defaults when present let defaults_file = "/usr/share/vim/vim" \ . (v:version / 100) . (v:version % 10) \ . "/defaults.vim" if filereadable(defaults_file) execute "source " . defaults_file endif " mouse in vim confuses me set mouse= " quickly toggle paste mode set pastetoggle= " spell check in English (US) " disable with `setlocal nospell` " add words to dictionary with `zg` setlocal spell spelllang=en_us " use `\s` for spell suggestions drop-down nnoremap \s ea " Mark tabs and trailing whitespace set listchars=tab:‗‗,trail:‗ set list if executable("powerline") " Set up powerline, see " https://powerline.readthedocs.io/en/latest/troubleshooting.html#my-vim-statusline-is-hidden-only-appears-in-split-windows set laststatus=2 endif if filereadable("/usr/lib/ycmd/ycm_extra_conf.py") " Set up youcompleteme let g:ycm_global_ycm_extra_conf = "/usr/lib/ycmd/ycm_extra_conf.py" filetype on endif " set up `cscope` " this was adapted from " https://vimhelp.org/if_cscop.txt.html#cscope-suggestions if has("cscope") set cscopetagorder=0 set cscopetag " add any database in current directory set nocscopeverbose if filereadable("cscope.out") cscope add cscope.out " else add database pointed to by environment elseif "${CSCOPE_DB}" != "" cscope add "${CSCOPE_DB}" endif set cscopeverbose " add common shortcuts " " s: Find this C symbol " g: Find this definition " d: Find functions called by this function " c: Find functions calling this function " t: Find this text string " e: Find this egrep pattern " f: Find this file " i: Find files #including this file " a: Find places where this symbol is assigned a value " nmap gss :cscope find s =expand("") nmap gsg :cscope find g =expand("") nmap gsd :cscope find d =expand("") nmap gsc :cscope find c =expand("") nmap gst :cscope find t =expand("") nmap gse :cscope find e =expand("") nmap gsf :cscope find f =expand("") nmap gsi :cscope find i =expand("") nmap gsa :cscope find a =expand("") endif " source: https://vim.fandom.com/wiki/Search_for_visually_selected_text#Advanced " Search for selected text, forwards or backwards. vnoremap * : \let old_reg=getreg('"')let old_regtype=getregtype('"') \gvy/=&ic?'\c':'\C'=substitute( \escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g') \gVzv:call setreg('"', old_reg, old_regtype) vnoremap # : \let old_reg=getreg('"')let old_regtype=getregtype('"') \gvy?=&ic?'\c':'\C'=substitute( \escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g') \gVzv:call setreg('"', old_reg, old_regtype) " Enable auto-indentation for convenient editing set autoindent set smartindent " Enable hidden mode for convenient buffer handling set hidden " Let vim match colors for better readability set background=dark " Store swap files in a directory where they don't disturb the sight. silent exec "!mkdir -p ~/.vim/swapfiles" set directory=$HOME/.vim/swapfiles// " Show relative line numbers for faster vertical movement. set relativenumber " Show current line number to keep us oriented. set number