" .vimrc " 07feb2008 +chris+ " 29sep2009 +chris+ " 14aug2019 +leah+ clean up autocmd! " General options set rulerformat=%-13.(%l/%L%)\ %P set ruler set tabstop=8 set softtabstop=2 set shiftwidth=2 set expandtab autocmd BufRead * silent g/^\t/setl sts=0 sw=8 noet|norm!`` autocmd BufNewFile,BufRead template setl sts=0 sw=0 noet nf-=octal set visualbell set backup autocmd BufNewFile,BufRead *:2\,* setl nobackup ft=mail set autoread set textwidth=70 set virtualedit=block set history=100 set viminfo+=% set showcmd set titlestring=%{hostname()}:\ vim\ %F%a " More Emacsish set backspace=indent,eol,start set selection=exclusive set incsearch set shiftround set joinspaces set whichwrap+=<,> set ignorecase set smartcase set showmatch set nohlsearch set hidden set winminheight=0 cmap set showbreak=\\ set cinkeys=0{,0},:,0#,0,!^F set noautoindent set nofixeol set display+=truncate " no lame menus set wildmenu set completeopt=preview set wildmode=longest,list " annoys to no end map q: : set cedit=^F set nofoldenable set t_ti= t_te= " dont use secondary screen command! -bang -nargs=? -complete=file W w command! -bang -nargs=? -complete=file Wq wq command! -bang -nargs=? -complete=file WQ wq " behaves like :q for windows, but for buffers command! -bang Q :if len(filter(range(1,bufnr('$')),'bufloaded(v:val)'))==1 | q | else | bd | endif command! -nargs=? Help help " shortcuts for quickfix nnoremap _ :cprev nnoremap + :cnext nnoremap &buftype ==# 'quickfix' ? ':bd' : ':cw\|silent only' " close quickfix after jumping autocmd BufReadPost quickfix nmap :.cc\|silent only " no wrap in quickfix " 01sep2016 +chris+ autocmd BufReadPost quickfix setl nowrap " shortcuts for cycling buffers " 21dec2018 +leah+ nnoremap :bn nnoremap :bp " .xbps files " 03feb2017 +leah+ au BufReadCmd *.xbps call tar#Browse(expand("")) " resize windows on terminal size change autocmd VimResized * wincmd = let g:tex_flavor='pdflatex' let s:tlist_def_tex_settings = 'tex;s:section;c:chapter;l:label;r:ref' let g:surround_{char2nr('c')} = "\\\1command\1{\r}" runtime macros/matchit.vim filetype plugin indent on try syntax on colorscheme chris2 # disable conceal in help autocmd FileType help syn off catch syntax off set background=dark endtry " === custom stuff === " zi: insert one char map zi i$r " Q reflows the current paragraph/selection map Q gwap vmap Q gq " custom text-objects (thx romainl) for char in [ '_', '.', ':', ',', ';', '', '/', '', '*', '+', '%', '$' ] execute 'xnoremap i' . char . ' :normal! T' . char . 'vt' . char . '' execute 'onoremap i' . char . ' :normal vi' . char . '' execute 'xnoremap a' . char . ' :normal! F' . char . 'vf' . char . '' execute 'onoremap a' . char . ' :normal va' . char . '' endfor " aa selects everything in visual selection mode xnoremap aa :mark ' \| keepj norm! ggVG " keep visual selection when reindenting xnoremap > >gv xnoremap < :stop " whitespace under cursor as text object onoremap a :let r=@/ \| let @/="\\s*\\(\\%#\\&\\s\\)\\s*" \| :exe "normal! gn" \| let @/=r onoremap i :let r=@/ \| let @/="\\s\\@<=\\s*\\(\\%#\\&\\s\\)\\s*" \| :exe "normal! gn" \| let @/=r " compress whitespace " nmap g :s/\s*\%#\s*/ /e nmap g dai " yay, emacs-style command line editing cnoremap cnoremap cnoremap cnoremap estrpart(getcmdline(),0,getcmdpos()-1) " save as root command! WW :w !sudo tee % >/dev/null " diffput current line only nmap dP :.diffput " g. to open directory file is in nmap g. :e %:h " g* to execute the current line as macro nmap g* my"yyy@y`y " g! to execute the current line as shell command nmap g! :exe "!".getline('.') " jump to the next end-of-word location, and reenter insert mode " https://math.berkeley.edu/~gbergman/misc/hacks/vi.html imap Ea " easier "0p nnoremap 0p "0p " easier :%s///g nnoremap S :%s//g vnoremap S :s//g " g= indent line/selection as much as line above nmap g= :le =indent(line('.')-1) vmap g= :'<,'>le =indent(line('v')-1) " Various Leader macros " sort words in string nmap r :.!perl -pe 's/"\K(.*?)(?=")/join(" ",sort(split(" ", $1)))/eg' " put word in braces nmap q bi{ea} " insert date in my format nmap d a=tolower(strftime("%d%b%Y"))." +".$USER."+" " keep .orig nmap o :set patchmode=.orig " load haskell nmap l :call term_sendkeys('!ghci', ":load ".expand('%:p')."\r") " sort paragraph (e.g. includes) nmap s vip:sort " bump revisit timestamp nmap b :.!revisit -b " fix my name command! Leah %s/Christian Neukirchen /Leah Neukirchen /ge | %s/chneukirchen@gmail.com/leah@vuxu.org/ge | %s/Christian Neukirchen/Leah Neukirchen/ge | %s/+chris+/+leah+/ge | %s/chris2/leah2/ge " :R to execute command with output to a scratch buffer command! -n=* -complete=shellcmd R new|setl bt=nofile noswf|exe "0r!" |0 " :Lr to wrap lr(1) and open files on return command! -n=* -complete=file Lr silent exe "R" "lr" | res | silent f [lr] | map $hgF " :Mo to move last visual to the line below command! Mo k` | '<,'>m . | norm ``j " disable automatic insertion of comment markers set fo=cjql autocmd FileType * setl fo-=o fo-=r autocmd FileType gitcommit setl fo=cjql com+=n:> let g:netrw_http_cmd="curl -Ls -o" let g:netrw_ftp_cmd="tnftp" let g:netrw_uid="anonymous" " hide dotfiles by default, use 'a' to cycle let g:netrw_list_hide='\(^\|\s\s\)\zs\.\S\+' let g:GPGExecutable="gpg2" set dictionary=/usr/share/dict/words if has("gui_running") set columns=80 set lines=50 set guifont=Fixed\ Medium\ Semi-Condensed\ 10 " Lightweight interface set guioptions=aegitl " Nonblinking cursor set gcr=a:blinkon0 endif if &diff " don't fold set diffopt+=context:1000000 highlight! link DiffText MatchParen highlight! link DiffChange Normal highlight! link DiffDelete Conceal end " hard mode " 06jun2016 +chris+ noremap noremap noremap noremap inoremap inoremap inoremap inoremap " site-local config " 31oct2017 +leah+ silent! source ~/.vimrc.local