Skip to content

Commit

Permalink
Merge pull request #3 from Baramin/master
Browse files Browse the repository at this point in the history
Slight modification to prevent vim complaints when reloading
  • Loading branch information
Bit Connor committed Nov 24, 2011
2 parents 14b329f + b6112c6 commit d13882e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions plugin/bad-whitespace.vim
Expand Up @@ -2,7 +2,7 @@
" Maintainer: Bit Connor <bit@mutantlemon.com> " Maintainer: Bit Connor <bit@mutantlemon.com>
" Version: 0.2 " Version: 0.2


function s:ShowBadWhitespace(force) function! s:ShowBadWhitespace(force)
if a:force if a:force
let b:bad_whitespace_show = 1 let b:bad_whitespace_show = 1
endif endif
Expand All @@ -13,14 +13,14 @@ function s:ShowBadWhitespace(force)
autocmd InsertEnter <buffer> match BadWhitespace /\s\+\%#\@<!$/ autocmd InsertEnter <buffer> match BadWhitespace /\s\+\%#\@<!$/
endfunction endfunction


function s:HideBadWhitespace(force) function! s:HideBadWhitespace(force)
if a:force if a:force
let b:bad_whitespace_show = 0 let b:bad_whitespace_show = 0
endif endif
match none BadWhitespace match none BadWhitespace
endfunction endfunction


function s:EnableShowBadWhitespace() function! s:EnableShowBadWhitespace()
if exists("b:bad_whitespace_show") if exists("b:bad_whitespace_show")
return return
endif endif
Expand All @@ -31,7 +31,7 @@ function s:EnableShowBadWhitespace()
endif endif
endfunction endfunction


function s:ToggleBadWhitespace() function! s:ToggleBadWhitespace()
if !exists("b:bad_whitespace_show") if !exists("b:bad_whitespace_show")
let b:bad_whitespace_show = 0 let b:bad_whitespace_show = 0
if &modifiable if &modifiable
Expand All @@ -47,14 +47,14 @@ endfunction


autocmd BufWinEnter,WinEnter,FileType * call <SID>EnableShowBadWhitespace() autocmd BufWinEnter,WinEnter,FileType * call <SID>EnableShowBadWhitespace()


function s:EraseBadWhitespace(line1,line2) function! s:EraseBadWhitespace(line1,line2)
let l:save_cursor = getpos(".") let l:save_cursor = getpos(".")
silent! execute ':' . a:line1 . ',' . a:line2 . 's/\s\+$//' silent! execute ':' . a:line1 . ',' . a:line2 . 's/\s\+$//'
call setpos('.', l:save_cursor) call setpos('.', l:save_cursor)
endfunction endfunction


" Run :EraseBadWhitespace to remove end of line white space. " Run :EraseBadWhitespace to remove end of line white space.
command -range=% EraseBadWhitespace call <SID>EraseBadWhitespace(<line1>,<line2>) command! -range=% EraseBadWhitespace call <SID>EraseBadWhitespace(<line1>,<line2>)
command ShowBadWhitespace call <SID>ShowBadWhitespace(1) command! ShowBadWhitespace call <SID>ShowBadWhitespace(1)
command HideBadWhitespace call <SID>HideBadWhitespace(1) command! HideBadWhitespace call <SID>HideBadWhitespace(1)
command ToggleBadWhitespace call <SID>ToggleBadWhitespace() command! ToggleBadWhitespace call <SID>ToggleBadWhitespace()

0 comments on commit d13882e

Please sign in to comment.