Skip to content

Commit b046e91

Browse files
committed
Add setting for verbose output. Disable by default.
1 parent 9b50242 commit b046e91

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ Whitespace highlighting is enabled by default, with a highlight color of red.
9999
let g:better_whitespace_filetypes_blacklist=['<filetype1>', '<filetype2>', '<etc>']
100100
```
101101
102+
* To enable verbose output for each command, set verbosity in your `.vimrc`:
103+
```
104+
let g:better_whitespace_verbosity=1
105+
```
106+
102107
##Screenshots
103108
Here are a couple more screenshots of the plugin at work.
104109

plugin/better-whitespace.vim

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ call s:InitVariable('g:strip_whitespace_on_save', 0)
3636
let default_blacklist=['diff', 'gitcommit', 'unite', 'qf', 'help']
3737
call s:InitVariable('g:better_whitespace_filetypes_blacklist', default_blacklist)
3838

39+
" Disable verbosity by default
40+
call s:InitVariable('g:better_whitespace_verbosity', 0)
41+
3942
" Only init once
4043
let s:better_whitespace_initialized = 0
4144

@@ -67,6 +70,13 @@ function! s:WhitespaceInit()
6770
let s:better_whitespace_initialized = 1
6871
endfunction
6972

73+
" Like 'echo', but only outputs the message when verbosity is enabled
74+
function! s:Echo(message)
75+
if g:better_whitespace_verbosity == 1
76+
echo a:message
77+
endif
78+
endfunction
79+
7080
" Enable the whitespace highlighting
7181
function! s:EnableWhitespace()
7282
if g:better_whitespace_enabled == 0
@@ -75,7 +85,7 @@ function! s:EnableWhitespace()
7585
" Match default whitespace
7686
call s:InAllWindows('match ExtraWhitespace /\s\+$/')
7787
call <SID>SetupAutoCommands()
78-
echo "Whitespace Highlighting: Enabled"
88+
call <SID>Echo("Whitespace Highlighting: Enabled")
7989
endif
8090
endfunction
8191

@@ -86,7 +96,7 @@ function! s:DisableWhitespace()
8696
" Clear current whitespace matches
8797
call s:InAllWindows("match ExtraWhitespace '' | syn clear ExtraWhitespace")
8898
call <SID>SetupAutoCommands()
89-
echo "Whitespace Highlighting: Disabled"
99+
call <SID>Echo("Whitespace Highlighting: Disabled")
90100
endif
91101
endfunction
92102

@@ -112,12 +122,12 @@ function! s:CurrentLineWhitespaceOff( level )
112122
let g:current_line_whitespace_disabled_hard = 1
113123
let g:current_line_whitespace_disabled_soft = 0
114124
call s:InAllWindows('syn clear ExtraWhitespace | match ExtraWhitespace /\s\+$/')
115-
echo "Current Line Hightlight Off (hard)"
125+
call <SID>Echo("Current Line Hightlight Off (hard)")
116126
elseif a:level == 'soft'
117127
let g:current_line_whitespace_disabled_soft = 1
118128
let g:current_line_whitespace_disabled_hard = 0
119129
call s:InAllWindows("match ExtraWhitespace ''")
120-
echo "Current Line Hightlight Off (soft)"
130+
call <SID>Echo("Current Line Hightlight Off (soft)")
121131
endif
122132
" Re-run auto commands with the new settings
123133
call <SID>SetupAutoCommands()
@@ -131,7 +141,7 @@ function! s:CurrentLineWhitespaceOn()
131141
let g:current_line_whitespace_disabled_soft = 0
132142
call <SID>SetupAutoCommands()
133143
call s:InAllWindows('syn clear ExtraWhitespace | match ExtraWhitespace /\s\+$/')
134-
echo "Current Line Hightlight On"
144+
call <SID>Echo("Current Line Hightlight On")
135145
endif
136146
endfunction
137147

@@ -154,10 +164,10 @@ endfunction
154164
function! s:ToggleStripWhitespaceOnSave()
155165
if g:strip_whitespace_on_save == 0
156166
let g:strip_whitespace_on_save = 1
157-
echo "Strip Whitespace On Save: Enabled"
167+
call <SID>Echo("Strip Whitespace On Save: Enabled")
158168
else
159169
let g:strip_whitespace_on_save = 0
160-
echo "Strip Whitespace On Save: Disabled"
170+
call <SID>Echo("Strip Whitespace On Save: Disabled")
161171
endif
162172
call <SID>SetupAutoCommands()
163173
endfunction

0 commit comments

Comments
 (0)