diff --git a/plugin/ShowTrailingWhitespace.vim b/plugin/ShowTrailingWhitespace.vim index b6494d1..cff87f2 100644 --- a/plugin/ShowTrailingWhitespace.vim +++ b/plugin/ShowTrailingWhitespace.vim @@ -1,6 +1,7 @@ " ShowTrailingWhitespace.vim: Detect and delete unwanted whitespace at the end of lines. " " DEPENDENCIES: +" - ShowTrailingWhitespace.vim autoload script. " " Copyright: (C) 2012 Ingo Karkat " The VIM LICENSE applies to this script; see ':help copyright'. @@ -8,6 +9,9 @@ " Maintainer: Ingo Karkat " " REVISION DATE REMARKS +" 002 26-Feb-2012 Move functions to autoload script. +" Rewrite example commands with new autoload +" functions. " 001 25-Feb-2012 file creation " Avoid installing twice or when in unsupported Vim version. @@ -20,55 +24,18 @@ if ! exists('g:ShowTrailingWhitespace') let g:ShowTrailingWhitespace = 1 endif -function! s:UpdateMatch( isInsertMode ) - let l:pattern = (a:isInsertMode ? '\s\+\%#\@Detect(0) - autocmd InsertEnter * call Detect(1) + autocmd BufWinEnter,InsertLeave * call ShowTrailingWhitespace#Detect(0) + autocmd InsertEnter * call ShowTrailingWhitespace#Detect(1) augroup END highlight def link ShowTrailingWhitespace Error -"command! -bar ShowTrailingWhitespaceOn let g:ShowTrailingWhitespace = 1 | call DetectAll() -"command! -bar ShowTrailingWhitespaceOff let g:ShowTrailingWhitespace = 0 | call DetectAll() -"command! -bar ShowTrailingWhitespaceBufferOn let b:ShowTrailingWhitespace = 1 | call UpdateMatch(0) -"command! -bar ShowTrailingWhitespaceBufferOff let b:ShowTrailingWhitespace = 0 | call DeleteMatch() -"command! -bar ShowTrailingWhitespaceBufferClear unlet! b:ShowTrailingWhitespace | call Detect(0) +command! -bar ShowTrailingWhitespaceOn call ShowTrailingWhitespace#Set(1,1) +command! -bar ShowTrailingWhitespaceOff call ShowTrailingWhitespace#Set(0,1) +command! -bar ShowTrailingWhitespaceBufferOn call ShowTrailingWhitespace#Set(1,0) +command! -bar ShowTrailingWhitespaceBufferOff call ShowTrailingWhitespace#Set(0,0) +command! -bar ShowTrailingWhitespaceBufferClear call ShowTrailingWhitespace#Reset() " vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax :