mirror of
https://github.com/bronson/vim-trailing-whitespace.git
synced 2025-11-08 11:33:54 -05:00
Stop the script from double execution with a "loaded" variable
This commit is contained in:
@@ -1,8 +1,12 @@
|
|||||||
|
if exists('loaded_trailing_whitespace_plugin') | finish | endif
|
||||||
|
let loaded_trailing_whitespace_plugin = 1
|
||||||
|
|
||||||
" Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces
|
" Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces
|
||||||
highlight ExtraWhitespace ctermbg=darkred guibg=#382424
|
highlight ExtraWhitespace ctermbg=darkred guibg=#382424
|
||||||
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
|
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
|
||||||
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
|
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
|
||||||
" the above flashes annoyingly while typing, be calmer in insert mode
|
|
||||||
|
" The above flashes annoyingly while typing, be calmer in insert mode
|
||||||
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
|
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
|
||||||
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
|
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
|
||||||
|
|
||||||
@@ -12,6 +16,5 @@ function! s:FixWhitespace(line1,line2)
|
|||||||
call setpos('.', l:save_cursor)
|
call setpos('.', l:save_cursor)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Run :FixWhitespace to remove end of line white space.
|
" Run :FixWhitespace to remove end of line white space
|
||||||
command! -range=% FixWhitespace call <SID>FixWhitespace(<line1>,<line2>)
|
command! -range=% FixWhitespace call <SID>FixWhitespace(<line1>,<line2>)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user