所以,我在我的vimrc中有以下几块:
" This toggles the hilighting of trailing-whitespace.
fun! ToggleExtraWhitespace()
if exists('b:ews') && b:ews == 1
"echom "Disabling trailing-whitespace hilighting in" bufnr('%') "..."
let b:ews=0
call HighlightExtraWhitespace()
"echom "-- Removing ExtraWhitespace augroup"
au! ExtraWhitespace
augroup! ExtraWhitespace
else
"echom "Enabling trailing-whitespace hilighting in" bufnr('%') "..."
let b:ews=1
call HighlightExtraWhitespace()
"echom "-- Adding ExtraWhitespace augroup"
augroup ExtraWhitespace
au!
au BufEnter * match ExtraWhitespace /\s\+$/
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhiteSpace /\s\+$/
augroup END
if mode() == "i" | do ExtraWhitespace InsertEnter | else | do ExtraWhitespace BufEnter | endif
endif
endfun
" This adds (or removes) the actual hilighting to your ColourScheme. (It's must be re-called every
" time you toggle hilighting, or change your scheme.)
fun! HighlightExtraWhitespace()
if exists('b:ews') && b:ews == 1
"echom "-- Adding ExtraWhitespace hilighting"
highlight ExtraWhitespace ctermbg=red guibg=red
else
"echom "-- Removing ExtraWhitespace hilighting"
highlight clear ExtraWhitespace
endif
endfun
au ColorScheme * call HighlightExtraWhitespace()
" (Uncomment the following line if you want trailing-whitespace hilighted by default!)
bufdo call ToggleExtraWhitespace() | au BufAdd * call ToggleExtraWhitespace()
然而,我刚刚意识到,这阻止了我在一个命令行命令中打开多个文件(我通常在内部浏览,因此我花了这么长时间注意!):nvim -o lib/ocameel.ml bin/cli.ml
打开包含cli.ml
的两个缓冲区,并且根本不会打开lib/ocameel.ml
!
如果我评论最后一行,一切正常;我仍然可以手动调用:call ToggleExtraWhitespace()
,并且所有内容都是hunky-dory。
我真的很想弄清楚,为什么添加自动命令会破坏vim-entry。我的BufAdd搞砸了什么? D: