Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ Whitespace highlighting is enabled by default, with a highlight color of red.
let g:better_whitespace_verbosity=1
```

* To skip lines that contain only whitespace, set the following in your `.vimrc`:
```
let g:better_whitespace_skip_empty_lines=1
```

## Supported Whitespace Characters
Due to the fact that the built-in whitespace character class for patterns (`\s`)
only matches against tabs and spaces, this plugin defines its own list of
Expand Down
10 changes: 7 additions & 3 deletions plugin/better-whitespace.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,13 @@ call s:InitVariable('g:better_whitespace_verbosity', 0)

" Define custom whitespace character group to include all horizontal unicode
" whitespace characters. Vim's '\s' class only includes ASCII spaces and tabs.
let s:whitespace_group='[\u0009\u0020\u00a0\u1680\u180e\u2000-\u200b\u202f\u205f\u3000\ufeff]'
let s:eol_whitespace_pattern = s:whitespace_group . '\+$'
let s:whitespace_chars='\u0009\u0020\u00a0\u1680\u180e\u2000-\u200b\u202f\u205f\u3000\ufeff'
let s:eol_whitespace_pattern = '[' . s:whitespace_chars . ']\+$'

call s:InitVariable('g:better_whitespace_skip_empty_lines', 0)
if g:better_whitespace_skip_empty_lines == 1
let s:eol_whitespace_pattern = '[^' . s:whitespace_chars . ']\@1<=' . s:eol_whitespace_pattern
endif

" Only init once
let s:better_whitespace_initialized = 0
Expand Down Expand Up @@ -292,4 +297,3 @@ function! <SID>SetupAutoCommands()

augroup END
endfunction