Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make autocmds for whitespace highlights/deletions buffer-specific #168

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions plugin/better-whitespace.vim
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ endfunction
function! <SID>SetupAutoCommands()
augroup better_whitespace
" Reset all auto commands in group
autocmd!
autocmd! * <buffer>

if <SID>ShouldHighlight()
if s:better_whitespace_initialized == 0
Expand All @@ -354,19 +354,19 @@ function! <SID>SetupAutoCommands()

" Highlight extraneous whitespace at the end of lines, but not the current line in insert mode.
call <SID>HighlightEOLWhitespace()
autocmd CursorMovedI,InsertEnter * call <SID>HighlightEOLWhitespaceExceptCurrentLine()
autocmd InsertLeave,BufReadPost * call <SID>HighlightEOLWhitespace()
autocmd CursorMovedI,InsertEnter <buffer> call <SID>HighlightEOLWhitespaceExceptCurrentLine()
autocmd InsertLeave,BufReadPost <buffer> call <SID>HighlightEOLWhitespace()

if g:current_line_whitespace_disabled_soft == 0
" Using syntax: clear whitespace highlighting when leaving buffer
autocmd BufWinLeave * if expand("<afile>") == expand("%") | call <SID>ClearHighlighting() | endif
autocmd BufWinLeave <buffer> if expand("<afile>") == expand("%") | call <SID>ClearHighlighting() | endif

" Do not highlight whitespace on current line in insert mode
autocmd CursorMovedI * call <SID>HighlightEOLWhitespaceExceptCurrentLine()
autocmd CursorMovedI <buffer> call <SID>HighlightEOLWhitespaceExceptCurrentLine()

" Do not highlight whitespace on current line in normal mode?
if g:current_line_whitespace_disabled_hard == 1
autocmd CursorMoved * call <SID>HighlightEOLWhitespaceExceptCurrentLine()
autocmd CursorMoved <buffer> call <SID>HighlightEOLWhitespaceExceptCurrentLine()
endif
endif

Expand All @@ -377,7 +377,7 @@ function! <SID>SetupAutoCommands()

" Strip whitespace on save if enabled.
if <SID>ShouldStripWhitespaceOnSave()
autocmd BufWritePre * call <SID>StripWhitespaceOnSave(v:cmdbang)
autocmd BufWritePre <buffer> call <SID>StripWhitespaceOnSave(v:cmdbang)
endif

augroup END
Expand Down