aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vim/doc/strip_trailing_whitespace.txt3
-rw-r--r--vim/plugin/strip_trailing_whitespace.vim11
2 files changed, 12 insertions, 2 deletions
diff --git a/vim/doc/strip_trailing_whitespace.txt b/vim/doc/strip_trailing_whitespace.txt
index 670877c9..d50fbfb7 100644
--- a/vim/doc/strip_trailing_whitespace.txt
+++ b/vim/doc/strip_trailing_whitespace.txt
@@ -7,6 +7,9 @@ This plugin is the author's approach to stripping trailing whitespace from an
entire buffer, including empty lines at the end, without making command noise
and without moving the cursor from its current position.
+If also provides a :StripTrailingWhitespace command if you have +user_commands,
+but this is not required.
+
This plugin lives in Tom Ryder's "dotfiles" suite, and will eventually be spun
off into a separate distribution as it solidifies and this documentation
improves.
diff --git a/vim/plugin/strip_trailing_whitespace.vim b/vim/plugin/strip_trailing_whitespace.vim
index 9fb2e65b..1264a11f 100644
--- a/vim/plugin/strip_trailing_whitespace.vim
+++ b/vim/plugin/strip_trailing_whitespace.vim
@@ -1,6 +1,6 @@
"
-" strip_trailing_whitespace.vim: User-defined key mapping to strip trailing
-" whitespace in the whole document.
+" strip_trailing_whitespace.vim: User-defined key mapping and optional command
+" to strip trailing whitespace in the whole document.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
@@ -67,3 +67,10 @@ endfunction
noremap <silent> <unique>
\ <Plug>StripTrailingWhitespace
\ :<C-U>call <SID>StripTrailingWhitespace()<CR>
+
+" Define a user command too, if we can
+if has('user_commands')
+ command -nargs=0
+ \ StripTrailingWhiteSpace
+ \ call <SID>StripTrailingWhitespace()
+endif