Skip to content

Commit

Permalink
Add a configurable variable of the highlight of trailing whitespace (#89
Browse files Browse the repository at this point in the history
)
  • Loading branch information
huangzonghao authored and ntpeters committed Jun 11, 2018
1 parent 4b27acb commit 70a38fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -34,6 +34,16 @@ Whitespace highlighting is enabled by default, with a highlight color of red.
```vim
highlight ExtraWhitespace ctermbg=<desired_color>
```
or

```vim
let g:better_whitespace_ctermcolor='<desired_color>'
```
Similarly, to set gui color:

```vim
let g:better_whitespace_guicolor='<desired_color>'
```

* To enable highlighting and stripping whitespace on save by default, use respectively
```vim
Expand Down
6 changes: 5 additions & 1 deletion plugin/better-whitespace.vim
Expand Up @@ -15,6 +15,10 @@ function! s:InitVariable(var, value)
endif
endfunction

" Set the highlight color for trailing whitespaces
call s:InitVariable('g:better_whitespace_ctermcolor', 'red')
call s:InitVariable('g:better_whitespace_guicolor', '#FF0000')

" Operator for StripWhitespace (empty to disable)
call s:InitVariable('g:better_whitespace_operator', '<leader>s')

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

0 comments on commit 70a38fa

Please sign in to comment.