mirror of
https://github.com/bronson/vim-trailing-whitespace.git
synced 2025-11-09 12:03:54 -05:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5540b3faa2 | ||
|
|
99ef803ebd | ||
|
|
41f2489000 | ||
|
|
7816dc6b33 | ||
|
|
9b472b1f6e | ||
|
|
08bdb05c3d | ||
|
|
907174052a | ||
|
|
b822bad54c | ||
|
|
05f068ebd9 | ||
|
|
b5289251ae | ||
|
|
7c53389415 | ||
|
|
610ca1a97c | ||
|
|
c69b20f55d | ||
|
|
6b7cdecff2 | ||
|
|
901255e9af | ||
|
|
4c59654821 | ||
|
|
16e4d4dd27 | ||
|
|
733fb64337 | ||
|
|
8328b966ab | ||
|
|
d94d55177c | ||
|
|
5753ff3f30 | ||
|
|
8230c95010 | ||
|
|
1b7f4dcfdc | ||
|
|
4beb3bd490 | ||
|
|
7d55472713 | ||
|
|
8c9518306d | ||
|
|
478b217d29 | ||
|
|
c89fc0db1d | ||
|
|
c35e6ec061 | ||
|
|
01d9f26995 | ||
|
|
d4ad27de05 | ||
|
|
47af4b7137 | ||
|
|
0c79bd5f94 | ||
|
|
4234770084 | ||
|
|
7be1e55f10 | ||
|
|
6bfea0006a | ||
|
|
301a6dadbd |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
doc/tags
|
||||||
16
README
16
README
@@ -1,9 +1,15 @@
|
|||||||
This plugin causes all trailing whitespace to be highlighted in red.
|
This plugin causes trailing whitespace to be highlighted in red.
|
||||||
|
|
||||||
To fix the whitespace errors, just call :FixWhitespace. By default it
|
To fix the whitespace errors, call :FixWhitespace. By default it
|
||||||
operates on the entire file. Pass a range (or use V to select some lines)
|
operates on the entire file. Pass a range (or use V to select some lines)
|
||||||
to restrict the portion of the file that gets fixed.
|
to restrict the portion of the file that gets fixed.
|
||||||
|
|
||||||
Based on http://vim.wikia.com/wiki/Highlight_unwanted_spaces , and
|
The repo is at http://github.com/bronson/vim-trailing-whitespace
|
||||||
Thanks to http://github.com/graywh/dotfiles/blob/master/.vimrc#L452
|
|
||||||
for improving the fix command.
|
Originally based on http://vim.wikia.com/wiki/Highlight_unwanted_spaces
|
||||||
|
|
||||||
|
License: cc-by-sa. The instructions this plugin is based on were
|
||||||
|
licensed cc-by-sa so, until a reason to force a different license appears,
|
||||||
|
we'll continue to use it.
|
||||||
|
|
||||||
|
A more complete alternative is at https://github.com/ntpeters/vim-better-whitespace
|
||||||
|
|||||||
@@ -10,7 +10,17 @@ To fix the whitespace errors, just call :FixWhitespace. By default it
|
|||||||
operates on the entire file. Pass a range (or use V to select some lines)
|
operates on the entire file. Pass a range (or use V to select some lines)
|
||||||
to restrict the portion of the file that gets fixed.
|
to restrict the portion of the file that gets fixed.
|
||||||
|
|
||||||
Based on http://vim.wikia.com/wiki/Highlight_unwanted_spaces , and
|
The repo is at http://github.com/bronson/vim-trailing-whitespace
|
||||||
Thanks to http://github.com/graywh/dotfiles/blob/master/.vimrc#L452
|
|
||||||
for improving the fix command.
|
|
||||||
|
|
||||||
|
Originally based on http://vim.wikia.com/wiki/Highlight_unwanted_spaces
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
VARIABLES *FixWhitespace-variables*
|
||||||
|
|
||||||
|
g:extra_whitespace_ignored_filetypes
|
||||||
|
g:extra_whitespace_ignored_filetypes
|
||||||
|
You can set filetypes to be ignored for highlight into this variable.
|
||||||
|
|
||||||
|
let g:extra_whitespace_ignored_filetypes = ['unite', 'mkd']
|
||||||
|
|
||||||
|
The default value is [].
|
||||||
|
|||||||
@@ -1,17 +1,31 @@
|
|||||||
" Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces
|
if exists('loaded_trailing_whitespace_plugin') | finish | endif
|
||||||
highlight ExtraWhitespace ctermbg=darkred guibg=#382424
|
let loaded_trailing_whitespace_plugin = 1
|
||||||
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
|
|
||||||
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
|
|
||||||
" the above flashes annoyingly while typing, be calmer in insert mode
|
|
||||||
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
|
|
||||||
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
|
|
||||||
|
|
||||||
function! s:FixWhitespace(line1,line2)
|
if !exists('g:extra_whitespace_ignored_filetypes')
|
||||||
let l:save_cursor = getpos(".")
|
let g:extra_whitespace_ignored_filetypes = []
|
||||||
silent! execute ':' . a:line1 . ',' . a:line2 . 's/\s\+$//'
|
endif
|
||||||
call setpos('.', l:save_cursor)
|
|
||||||
|
function! ShouldMatchWhitespace()
|
||||||
|
for ft in g:extra_whitespace_ignored_filetypes
|
||||||
|
if ft ==# &filetype | return 0 | endif
|
||||||
|
endfor
|
||||||
|
if &buftype ==# 'terminal' | return 0 | endif
|
||||||
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Run :FixWhitespace to remove end of line white space.
|
" Highlight EOL whitespace, http://vim.wikia.com/wiki/Highlight_unwanted_spaces
|
||||||
command! -range=% FixWhitespace call <SID>FixWhitespace(<line1>,<line2>)
|
highlight default ExtraWhitespace ctermbg=darkred guibg=darkred
|
||||||
|
autocmd ColorScheme * highlight default ExtraWhitespace ctermbg=darkred guibg=darkred
|
||||||
|
let term_open_event = (has('nvim') ? 'TermOpen' : 'TerminalOpen')
|
||||||
|
exe 'autocmd BufRead,BufNew,FileType,' term_open_event '* if ShouldMatchWhitespace() | match ExtraWhitespace /\\\@<![\u3000[:space:]]\+$/ | else | match ExtraWhitespace /^^/ | endif'
|
||||||
|
|
||||||
|
" The above flashes annoyingly while typing, be calmer in insert mode
|
||||||
|
autocmd InsertLeave * if ShouldMatchWhitespace() | match ExtraWhitespace /\\\@<![\u3000[:space:]]\+$/ | endif
|
||||||
|
autocmd InsertEnter * if ShouldMatchWhitespace() | match ExtraWhitespace /\\\@<![\u3000[:space:]]\+\%#\@<!$/ | endif
|
||||||
|
|
||||||
|
function! s:FixWhitespace(line1,line2)
|
||||||
|
silent! keepjumps execute ':' . a:line1 . ',' . a:line2 . 's/\\\@<!\s\+$//'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Run :FixWhitespace to remove end of line white space
|
||||||
|
command! -range=% FixWhitespace call <SID>FixWhitespace(<line1>,<line2>)
|
||||||
|
|||||||
Reference in New Issue
Block a user