Skip to content

Commit 70a38fa

Browse files
huangzonghaontpeters
authored andcommitted
Add a configurable variable of the highlight of trailing whitespace (#89)
1 parent 4b27acb commit 70a38fa

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ Whitespace highlighting is enabled by default, with a highlight color of red.
3434
```vim
3535
highlight ExtraWhitespace ctermbg=<desired_color>
3636
```
37+
or
38+
39+
```vim
40+
let g:better_whitespace_ctermcolor='<desired_color>'
41+
```
42+
Similarly, to set gui color:
43+
44+
```vim
45+
let g:better_whitespace_guicolor='<desired_color>'
46+
```
3747
3848
* To enable highlighting and stripping whitespace on save by default, use respectively
3949
```vim

plugin/better-whitespace.vim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ function! s:InitVariable(var, value)
1515
endif
1616
endfunction
1717

18+
" Set the highlight color for trailing whitespaces
19+
call s:InitVariable('g:better_whitespace_ctermcolor', 'red')
20+
call s:InitVariable('g:better_whitespace_guicolor', '#FF0000')
21+
1822
" Operator for StripWhitespace (empty to disable)
1923
call s:InitVariable('g:better_whitespace_operator', '<leader>s')
2024

@@ -90,7 +94,7 @@ endfunction
9094
function! s:WhitespaceInit()
9195
" Check if the user has already defined highlighting for this group
9296
if hlexists("ExtraWhitespace") == 0 || synIDattr(synIDtrans(hlID("ExtraWhitespace")), "bg") == -1
93-
highlight ExtraWhitespace ctermbg = red guibg = #FF0000
97+
execute 'highlight ExtraWhitespace ctermbg = '.g:better_whitespace_ctermcolor. ' guibg = '.g:better_whitespace_guicolor
9498
endif
9599
let s:better_whitespace_initialized = 1
96100
endfunction

0 commit comments

Comments
 (0)