" restore cursor " from `:help restore-cursor` autocmd vimrc BufReadPost * \ : if line('''"') > 1 && line('''"') <= line('$') \ | execute 'normal! g`"' \ | endif " vim as a pager autocmd vimrc StdinReadPost * call user#pager() " auto make directories " from https://vim-jp.org/vim-users-jp/2011/02/20/Hack-202.html autocmd vimrc BufWritePre * \ call user#auto_mkdir(expand(':p:h'), v:cmdbang) " auto disable paste mode autocmd vimrc InsertLeave * setlocal nopaste " auto quickfix opener " from https://github.com/monaqa/dotfiles/blob/424b0ab2d7/.config/nvim/scripts/autocmd.vim autocmd vimrc QuickFixCmdPost [^l]* cwindow autocmd vimrc QuickFixCmdPost l* lwindow " faster syntax highlight autocmd vimrc Syntax * \ : if line('$') > 1000 \ | syntax sync minlines=100 \ | endif autocmd vimrc BufWinEnter * \ : if empty(&buftype) && line('.') > winheight(0) / 3 * 2 \ | execute 'normal! zz' .. repeat("\", winheight(0) / 6) \ | endif " from https://github.com/yuki-yano/dotfiles/blob/11bfe29f07/.vimrc#L696 autocmd vimrc FocusGained * checktime " from https://github.com/kuuote/dotvim/blob/46760385c2/conf/rc/autocmd.vim#L5 function! s:chmod(file) abort let perm = getfperm(a:file) let newperm = printf('%sx%sx%sx', perm[0:1], perm[3:4], perm[6:7]) if perm != newperm call setfperm(a:file, newperm) endif endfunction autocmd vimrc BufWritePost * \ : if getline(1) =~# '^#!/' \ | call s:chmod(expand('')) \ | endif " always highlight special comment autocmd vimrc ColorScheme * silent! hi def link TodoExt Todo autocmd vimrc BufEnter,WinEnter,Syntax * \ silent! let g:todo_match = matchadd('TodoExt', \ '\v\zs(TODO|NOTE|XXX|FIXME|INFO)\ze%(\(.{-}\))?\:') autocmd vimrc ColorScheme * \ : if &laststatus == 3 \ | hi clear VertSplit \ | endif autocmd vimrc BufWritePost * \ : if empty(&filetype) \ | filetype detect \ | endif autocmd vimrc SwapExists * \ : let v:swapchoice = 'o' \ | echohl ErrorMsg \ | echomsg 'Swapfile is found:' v:swapname \ | echohl NONE " from https://github.com/aiotter/dotfiles/blob/8e759221/.vimrc#L185 autocmd vimrc WinEnter * \ : if winnr('$') == 1 && &buftype ==# 'quickfix' \ | quit \ | endif autocmd vimrc VimResized * \ : if &equalalways \ | wincmd = \ | endif