aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-05-31 13:56:43 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-05-31 13:56:43 +1200
commitc68fcb332238ae6cb78a7bb01fc9f6eb413f2bc1 (patch)
tree1f06223020238460262ddf23d36384b6ab14f3dc
parentSpin off mail_mutt Vim plugin (diff)
downloaddotfiles-c68fcb332238ae6cb78a7bb01fc9f6eb413f2bc1.tar.gz
dotfiles-c68fcb332238ae6cb78a7bb01fc9f6eb413f2bc1.zip
Spin off strip_trailing_whitespace Vim plugin
-rw-r--r--.gitmodules3
-rw-r--r--Makefile9
m---------vim/bundle/strip_trailing_whitespace0
-rw-r--r--vim/doc/strip_trailing_whitespace.txt46
-rw-r--r--vim/plugin/strip_trailing_whitespace.vim75
5 files changed, 4 insertions, 129 deletions
diff --git a/.gitmodules b/.gitmodules
index c57005ed..5c6c56d7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -11,6 +11,9 @@
[submodule "vim/bundle/mail_mutt"]
path = vim/bundle/mail_mutt
url = https://sanctum.geek.nz/code/vim-mail-mutt.git
+[submodule "vim/bundle/strip_trailing_whitespace"]
+ path = vim/bundle/strip_trailing_whitespace
+ url = https://sanctum.geek.nz/code/vim-strip-trailing-whitespace.git
[submodule "vim/bundle/toggle_option_flags"]
path = vim/bundle/toggle_option_flags
url = https://sanctum.geek.nz/code/vim-toggle-option-flags.git
diff --git a/Makefile b/Makefile
index ff8b493c..5e006452 100644
--- a/Makefile
+++ b/Makefile
@@ -80,7 +80,6 @@
dist-vim-plugin-auto-undodir \
dist-vim-plugin-big-file-options \
dist-vim-plugin-command-typos \
- dist-vim-plugin-strip-trailing-whitespace
.SUFFIXES:
.SUFFIXES: .awk .bash .m4 .mi5 .pl .sed .sh
@@ -665,8 +664,7 @@ dist-vim-plugin: dist-vim-plugin-auto-backupdir \
dist-vim-plugin-auto-swapdir \
dist-vim-plugin-auto-undodir \
dist-vim-plugin-big-file-options \
- dist-vim-plugin-command-typos \
- dist-vim-plugin-strip-trailing-whitespace
+ dist-vim-plugin-command-typos
dist-vim-plugin-auto-backupdir: \
vim/plugin/auto_backupdir.vim \
@@ -693,8 +691,3 @@ dist-vim-plugin-command-typos: \
vim/doc/command_typos.txt \
VERSION
sh dist/vim-plugin.sh command_typos
-dist-vim-plugin-strip-trailing-whitespace: \
- vim/plugin/strip_trailing_whitespace.vim \
- vim/doc/strip_trailing_whitespace.txt \
- VERSION
- sh dist/vim-plugin.sh strip_trailing_whitespace
diff --git a/vim/bundle/strip_trailing_whitespace b/vim/bundle/strip_trailing_whitespace
new file mode 160000
+Subproject d64a7405e3bbfcb10cef99eb2795130504bce3a
diff --git a/vim/doc/strip_trailing_whitespace.txt b/vim/doc/strip_trailing_whitespace.txt
deleted file mode 100644
index 2b220231..00000000
--- a/vim/doc/strip_trailing_whitespace.txt
+++ /dev/null
@@ -1,46 +0,0 @@
-*strip_trailing_whitespace.txt* For Vim version 7.0 Last change: 2017 November 12
-
-DESCRIPTION *strip_trailing_whitespace*
-
-This plugin provides a mapping target and an optional custom command with the
-author's approach to stripping trailing whitespace from an entire buffer,
-including removing empty or whitespace-only lines at the end of the buffer,
-without making command noise and without moving the cursor from its current
-position.
-
-REQUIREMENTS *strip_trailing_whitespace-requirements*
-
-This plugin is only available if 'compatible' is not set.
-
-COMMANDS *strip_trailing_whitespace-commands*
-
- *:StripTrailingWhitespace*
-The plugin provides a single `:StripTrailingWhitespace` command if Vim has the
-|+user_commands| feature, but this is not required. It operates on the entire
-buffer, and accepts neither a range nor arguments.
-
-MAPPINGS *strip_trailing_whitespace-mappings*
-
- *<Plug>StripTrailingWhitespace*
-The single mapping target provided is |<Plug>StripTrailingWhitespace|,
-mappable in any mode. There is no default key mapping to the target; you
-should define this yourself in your |vimrc|. For example:
->
- :nmap <Leader>x <Plug>StripTrailingWhitespace>
-<
-AUTHOR *strip_trailing_whitespace-author*
-
-Written and maintained by Tom Ryder <tom@sanctum.geek.nz>.
-
-LICENSE *strip_trailing_whitespace-license*
-
-Licensed for distribution under the same terms as Vim itself (see |license|).
-
-DISTRIBUTION *strip_trailing_whitespace-distribution*
-
-This plugin lives in Tom Ryder's "dotfiles" suite, and may eventually be spun
-off into a separate distribution as it solidifies and this documentation
-improves. See <https://sanctum.geek.nz/cgit/dotfiles.git/about/> for more
-information.
-
- vim:tw=78:ts=8:ft=help:norl:
diff --git a/vim/plugin/strip_trailing_whitespace.vim b/vim/plugin/strip_trailing_whitespace.vim
deleted file mode 100644
index 1b6d2f38..00000000
--- a/vim/plugin/strip_trailing_whitespace.vim
+++ /dev/null
@@ -1,75 +0,0 @@
-"
-" 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
-"
-if exists('g:loaded_strip_trailing_whitespace') || &compatible
- finish
-endif
-let g:loaded_strip_trailing_whitespace = 1
-
-" Define function for stripping whitespace
-function! s:StripTrailingWhitespace()
-
- " Iterating line number
- let l:li = 1
-
- " Line number of last line that had non-whitespace characters on it
- let l:lw = 0
-
- " Line number of the file's last line
- let l:ll = line('$')
-
- " Iterate over the lines
- while l:li <= l:ll
-
- " Get the line text
- let l:line = getline(l:li)
-
- " Replace the line with a subsitution of its text stripping extraneous
- " whitespace
- call setline(l:li, substitute(l:line, '\m\C\s\+$', '', 'g'))
-
- " If this line has any non-whitespace characters on it, update l:lw with
- " its index
- if l:line =~# '\m\S'
- let l:lw = l:li
- endif
-
- " Increment the line counter for the next iteration
- let l:li = l:li + 1
-
- endwhile
-
- " If the last non-whitespace line was before the last line proper, we can
- " delete all lines after it
- if l:lw < l:ll
-
- " Get the current line and column so we can return to it
- " (Yes I know about winsaveview() and winrestview(); I want this to work
- " even on very old versions of Vim if possible)
- let l:lc = line('.')
- let l:cc = col('.')
-
- " Delete the lines, which will move the cursor
- silent execute l:lw + 1 . ',$ delete'
-
- " Return the cursor to the saved position
- call cursor(l:lc, l:cc)
- endif
-
-endfunction
-
-" Create mapping proxy to the function just defined
-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