@@ -33,7 +33,8 @@ call s:InitVariable('g:current_line_whitespace_disabled_soft', 0)
3333call s: InitVariable (' g:strip_whitespace_on_save' , 0 )
3434
3535" Set this to blacklist specific filetypes
36- call s: InitVariable (' g:better_whitespace_filetypes_blacklist' , [])
36+ let default_blacklist= [' diff' , ' gitcommit' , ' unite' , ' qf' , ' help' ]
37+ call s: InitVariable (' g:better_whitespace_filetypes_blacklist' , default_blacklist)
3738
3839" Only init once
3940let s: better_whitespace_initialized = 0
@@ -161,6 +162,11 @@ function! s:ToggleStripWhitespaceOnSave()
161162 call <SID> SetupAutoCommands ()
162163endfunction
163164
165+ " Determines if whitespace highlighting should currently be skipped
166+ function ! s: ShouldSkipHighlight ()
167+ return &buftype == ' nofile' || index (g: better_whitespace_filetypes_blacklist , &ft ) >= 0
168+ endfunction
169+
164170" Run :StripWhitespace to remove end of line whitespace
165171command ! -range =% StripWhitespace call <SID> StripWhitespace ( <line1> , <line2> )
166172" Run :ToggleStripWhitespaceOnSave to enable/disable whitespace stripping on save
@@ -186,7 +192,7 @@ function! <SID>SetupAutoCommands()
186192 augroup better_whitespace
187193 autocmd !
188194
189- if index ( g: better_whitespace_filetypes_blacklist , & ft ) >= 0
195+ if <SID> ShouldSkipHighlight ()
190196 match ExtraWhitespace ' '
191197 return
192198 endif
0 commit comments