@@ -16,7 +16,7 @@ function! s:InitVariable(var, value)
1616endfunction
1717
1818" Operator for StripWhitespace (empty to disable)
19- call s: InitVariable (' g:better_whitespace_operator' , ' <space> ' )
19+ call s: InitVariable (' g:better_whitespace_operator' , ' <leader>s ' )
2020
2121" Set this to enable/disable whitespace highlighting
2222call s: InitVariable (' g:better_whitespace_enabled' , 1 )
@@ -296,14 +296,24 @@ if !empty(g:better_whitespace_operator)
296296 call <SID> StripWhitespace (line (" '[" ), line (" ']" ))
297297 endfunction
298298
299- " Visual mode
300- exe " xmap <silent> " . g: better_whitespace_operator. " :StripWhitespace<CR> "
301- " Normal mode (+ space, with line count)
302- exe " nmap <silent> " .g: better_whitespace_operator ." <space> :<C-U>exe '.,+'.v:count' StripWhitespace' <CR>"
303- " Other motions
304- exe " nmap <silent> " . g: better_whitespace_operator . " :<C-U>set opfunc=<SID>StripWhitespaceMotion<CR>g@ "
305- endif
299+ " Ensure we only map if no identical, user-defined mapping already exists
300+ if ( empty ( mapcheck ( g: better_whitespace_operator, ' x ' )))
301+ " Visual mode
302+ exe " xmap <silent> " .g: better_whitespace_operator ." : StripWhitespace<CR>"
303+ else
304+ call <SID> Echo ( " Whitespace operator not mapped for visual mode. Mapping already exists. " )
305+ endif
306306
307+ " Ensure we only map if no identical, user-defined mapping already exists
308+ if (empty (mapcheck (g: better_whitespace_operator , ' n' )))
309+ " Normal mode (+ space, with line count)
310+ exe " nmap <silent> " .g: better_whitespace_operator ." <space> :<C-U>exe '.,+'.v:count' StripWhitespace'<CR>"
311+ " Other motions
312+ exe " nmap <silent> " .g: better_whitespace_operator ." :<C-U>set opfunc=<SID>StripWhitespaceMotion<CR>g@"
313+ else
314+ call <SID> Echo (" Whitespace operator not mapped for normal mode. Mapping already exists." )
315+ endif
316+ endif
307317
308318" Process auto commands upon load, update local enabled on filetype change
309319autocmd FileType * call <SID> ShouldSkipHighlight () | call <SID> SetupAutoCommands ()
0 commit comments