X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/e24c5f1fbc5a7d61116eb50f55e30cdc2bccb2c7..bb9addab88266679ad82852888c043a81f1f6b06:/vim/vimrc diff --git a/vim/vimrc b/vim/vimrc index 10e86f4..5a271cb 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -212,6 +212,7 @@ set viewoptions=cursor " only save cursor position set diffopt+=filler " show filler lines set diffopt+=vertical " always vertical split set diffopt+=iwhite " ignore white space +set diffopt+=context:10 " 10 lines context between changes " reading and writing files {{{2 set modeline " read modelines @@ -256,12 +257,17 @@ set wildignore+=*.luac " Lua byte code set wildignore+=*.pyc " Python byte code set wildignore+=*.orig " Merge resolution files +" language specific {{{2 +set isfname-== " don't treat `=` as being part of filenames + " various {{{2 set virtualedit=all " let cursor move past last char in mode set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache set viewdir=$XDG_CACHE_HOME/vim/view// +set sessionoptions+=unix,slash " damn windows and it's silly ways + " autocmds {{{1 " Resize splits when the window is resized {{{2 augroup resize @@ -293,6 +299,24 @@ augroup cursor_pos \ endif augroup END +" Check for file modifications automatically {{{2 +" (current buffer only) +" Use :NoAutoChecktime to disable it (uses b:autochecktime) +fun! MyAutoCheckTime() + " only check timestamp for normal files + if &buftype != '' | return | endif + if ! exists('b:autochecktime') || b:autochecktime + checktime % + let b:autochecktime = 1 + endif +endfun +augroup MyAutoChecktime + au! + au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime() +augroup END +command! NoAutoChecktime let b:autochecktime=0 +command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime + " bindings {{{1 " allow both and / to be @@ -314,8 +338,21 @@ nnoremap p* :silent! set paste"*p:set nopaste " paste from clipboard nnoremap p+ :silent! set paste"+p:set nopaste -" Clean trailing whitespace -nnoremap ww m':%s/\s\+$//:let @/=''``zz +" strip trailing whitespace +function! StripWhitespace(line1, line2, ...) " {{{2 + let s_report = &report + let &report=0 + let pattern = a:0 ? a:1 : '[\\]\@,) +nnoremap ww :Untrail " Source vnoremap S y:execute @@:echo 'Sourced selection.'