You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix various issues/PRs and update documentation (#72)
* Fix typo in README
* Buffer-local stripping of whitespace
* Add option to skip whitespace only lines, closes#65
* Add functions that jump to trailing white space
Closes#32
* Fix typo: Hightlight->Highlight
* A few more typo corrections.
* More typos
* Add option to strip white lines at EOF, closes#67
* Add operator for StripWhitespace (defaults to space)
Closes#18
* Match spaces that appear before or in-between tabs
This patch adds a option to enable matching of space characters that
appear before or in-between tabs. Removing such characters can be as
important as removing trailing white-space. This option is currently
disabled by default.
* Do not strip spaces before tabs
Only match them, see discussion on #58
* Update README and complete examples
3. While this plugin can also be installed by copying its contents into your `~/.vim/` directory, I would highly recommend using one of the above methods as they make managing your Vim plugins painless.
27
+
3. While this plugin can also be installed by copying its contents into your `~/.vim/` directory, I would
28
+
highly recommend using one of the above methods as they make managing your Vim plugins painless.
28
29
29
30
## Usage
30
31
Whitespace highlighting is enabled by default, with a highlight color of red.
31
32
32
33
* To set a custom highlight color, just call:
33
-
```
34
+
```vim
34
35
highlight ExtraWhitespace ctermbg=<desired_color>
35
36
```
36
37
37
-
* To toggle whitespace highlighting on/off, call:
38
+
* To enable highlighting and stripping whitespace on save by default, use respectively
39
+
```vim
40
+
let g:better_whitespace_enabled=1
41
+
let g:strip_whitespace_on_save=1
38
42
```
43
+
Set them to 0 to disable this default behaviour. See below for the blacklist of file types
44
+
and per-buffer settings.
45
+
46
+
* To enable/disable/toggle whitespace highlighting in a buffer, call one of:
47
+
```vim
48
+
:EnableWhitespace
49
+
:DisableWhitespace
39
50
:ToggleWhitespace
40
51
```
41
52
42
53
* To disable highlighting for the current line in normal mode call:
43
-
```
54
+
```vim
44
55
:CurrentLineWhitespaceOff <level>
45
56
```
46
57
Where `<level>` is either `hard` or `soft`.
@@ -55,69 +66,121 @@ Whitespace highlighting is enabled by default, with a highlight color of red.
55
66
priority highlighting.
56
67
57
68
* To re-enable highlighting for the current line in normal mode:
58
-
```
69
+
```vim
59
70
:CurrentLineWhitespaceOn
60
71
```
61
72
62
73
* To clean extra whitespace, call:
63
-
```
74
+
```vim
64
75
:StripWhitespace
65
76
```
66
77
By default this operates on the entire file. To restrict the portion of
67
78
the file that it cleans, either give it a range or select a group of lines
68
79
in visual mode and then execute it.
69
80
70
-
* To enable/disable stripping of extra whitespace on file save, call:
71
-
```
81
+
* There is an operator (defaulting to `<space>`) to clean whitespace.
82
+
For example, in normal mode, `<space>ip` will remove trailing whitespace from the
83
+
current paragraph.
84
+
85
+
You can change the operator it, for example to set it to _s, using:
86
+
```vim
87
+
let g:better_whitespace_operator='_s'
88
+
```
89
+
Now `<number>_s<space>` strips whitespace on \<number\> lines, and `_s<motion>` on the
90
+
lines affected by the motion given. Set to the empty string to deactivate the operator.
91
+
92
+
* To enable/disable stripping of extra whitespace on file save for a buffer, call one of:
93
+
```vim
94
+
:EnableStripWhitespaceOnSave
95
+
:DisableStripWhitespaceOnSave
72
96
:ToggleStripWhitespaceOnSave
73
97
```
74
98
This will strip all trailing whitespace everytime you save the file for all file types.
75
99
76
100
* If you want this behaviour by default for all filetypes, add the following to your `~/.vimrc`:
77
101
78
-
```
79
-
autocmd BufEnter * EnableStripWhitespaceOnSave
102
+
```vim
103
+
let g:strip_whitespace_on_save = 1
80
104
```
81
105
82
106
For exceptions of all see ```g:better_whitespace_filetypes_blacklist```.
83
107
84
108
* If you would prefer to only strip whitespace for certain filetypes, add
0 commit comments