From 1b7f4dcfdc776cb3260e27a77bbe630c37268e29 Mon Sep 17 00:00:00 2001 From: tyru Date: Sun, 10 Jan 2016 10:57:51 +0900 Subject: [PATCH 1/3] Make ShouldMatchWhitespace() script-local function --- plugin/trailing-whitespace.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/trailing-whitespace.vim b/plugin/trailing-whitespace.vim index 98025ce..158cca5 100644 --- a/plugin/trailing-whitespace.vim +++ b/plugin/trailing-whitespace.vim @@ -5,7 +5,7 @@ if !exists('g:extra_whitespace_ignored_filetypes') let g:extra_whitespace_ignored_filetypes = [] endif -function! ShouldMatchWhitespace() +function! s:ShouldMatchWhitespace() for ft in g:extra_whitespace_ignored_filetypes if ft ==# &filetype | return 0 | endif endfor @@ -15,11 +15,11 @@ endfunction " Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces highlight default ExtraWhitespace ctermbg=darkred guibg=#382424 autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red -autocmd BufRead,BufNew * if ShouldMatchWhitespace() | match ExtraWhitespace /\s\+$/ | else | match ExtraWhitespace /^^/ | endif +autocmd BufRead,BufNew * if s:ShouldMatchWhitespace() | match ExtraWhitespace /\s\+$/ | else | match ExtraWhitespace /^^/ | endif " The above flashes annoyingly while typing, be calmer in insert mode -autocmd InsertLeave * if ShouldMatchWhitespace() | match ExtraWhitespace /\s\+$/ | endif -autocmd InsertEnter * if ShouldMatchWhitespace() | match ExtraWhitespace /\s\+\%#\@ Date: Sun, 10 Jan 2016 10:59:52 +0900 Subject: [PATCH 2/3] Add 'default' to :highlight command Same as the command without 'autocmd ColorScheme *', add 'default' to :highlight command. --- plugin/trailing-whitespace.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/trailing-whitespace.vim b/plugin/trailing-whitespace.vim index 158cca5..9b908a6 100644 --- a/plugin/trailing-whitespace.vim +++ b/plugin/trailing-whitespace.vim @@ -14,7 +14,7 @@ endfunction " Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces highlight default ExtraWhitespace ctermbg=darkred guibg=#382424 -autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red +autocmd ColorScheme * highlight default ExtraWhitespace ctermbg=red guibg=red autocmd BufRead,BufNew * if s:ShouldMatchWhitespace() | match ExtraWhitespace /\s\+$/ | else | match ExtraWhitespace /^^/ | endif " The above flashes annoyingly while typing, be calmer in insert mode From 5753ff3f3049bfd3e3b8567bb570158d6f2da648 Mon Sep 17 00:00:00 2001 From: tyru Date: Sun, 10 Jan 2016 11:01:34 +0900 Subject: [PATCH 3/3] Support 'IDEOGRAPHIC SPACE' character (U+3000) http://www.fileformat.info/info/unicode/char/3000/index.htm --- plugin/trailing-whitespace.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/trailing-whitespace.vim b/plugin/trailing-whitespace.vim index 9b908a6..df184ad 100644 --- a/plugin/trailing-whitespace.vim +++ b/plugin/trailing-whitespace.vim @@ -15,11 +15,11 @@ endfunction " Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces highlight default ExtraWhitespace ctermbg=darkred guibg=#382424 autocmd ColorScheme * highlight default ExtraWhitespace ctermbg=red guibg=red -autocmd BufRead,BufNew * if s:ShouldMatchWhitespace() | match ExtraWhitespace /\s\+$/ | else | match ExtraWhitespace /^^/ | endif +autocmd BufRead,BufNew * if s:ShouldMatchWhitespace() | match ExtraWhitespace /[\u3000[:space:]]\+$/ | else | match ExtraWhitespace /^^/ | endif " The above flashes annoyingly while typing, be calmer in insert mode -autocmd InsertLeave * if s:ShouldMatchWhitespace() | match ExtraWhitespace /\s\+$/ | endif -autocmd InsertEnter * if s:ShouldMatchWhitespace() | match ExtraWhitespace /\s\+\%#\@