diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-12 23:32:44 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-12 23:32:44 +1200 |
commit | 6cd99a9510897e87fba76721b3c9d148c51a1649 (patch) | |
tree | 3c5a05cc7416070f7896f99535f31a77041e9768 | |
parent | Merge branch 'hotfix/v0.1.1' (diff) | |
parent | Bump VERSION (diff) | |
download | vim-squeeze-repeat-blanks-6cd99a9510897e87fba76721b3c9d148c51a1649.tar.gz vim-squeeze-repeat-blanks-6cd99a9510897e87fba76721b3c9d148c51a1649.zip |
Merge branch 'release/v0.2.0'v0.2.0
* release/v0.2.0:
Remove unneeded variable scoping
Switch to two-spacing
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | autoload/squeeze_repeat_blanks.vim | 24 | ||||
-rw-r--r-- | doc/squeeze_repeat_blanks.txt | 8 | ||||
-rw-r--r-- | plugin/squeeze_repeat_blanks.vim | 6 |
5 files changed, 21 insertions, 21 deletions
@@ -8,7 +8,7 @@ What constitutes a "blank" line is configurable per-buffer. License ------- -Copyright (c) [Tom Ryder][1]. Distributed under the same terms as Vim itself. +Copyright (c) [Tom Ryder][1]. Distributed under the same terms as Vim itself. See `:help license`. [1]: https://sanctum.geek.nz/ @@ -1 +1 @@ -0.1.1 +0.2.0 diff --git a/autoload/squeeze_repeat_blanks.vim b/autoload/squeeze_repeat_blanks.vim index 1429fcf..1b760b4 100644 --- a/autoload/squeeze_repeat_blanks.vim +++ b/autoload/squeeze_repeat_blanks.vim @@ -3,40 +3,40 @@ function! squeeze_repeat_blanks#Squeeze(start, end) abort " List of line numbers to delete - let l:deletions = [] + let deletions = [] " Flag for whether we've encountered a blank line group - let l:group = 0 + let group = 0 " Pattern for what constitutes a 'blank'; configurable per-buffer - let l:pattern = get(b:, 'squeeze_repeat_blanks_blank', '^$') + let pattern = get(b:, 'squeeze_repeat_blanks_blank', '^$') " Iterate through the lines, collecting numbers to delete - for l:num in range(a:start, a:end) + for num in range(a:start, a:end) " End a blank group if the current line doesn't match the pattern - if getline(l:num) !~# l:pattern - let l:group = 0 + if getline(num) !~# pattern + let group = 0 " If we've found a repeated blank line, flag the one before it for " deletion; this way we end up with the last line of the group - elseif l:group - let l:deletions += [l:num - 1] + elseif group + let deletions += [num - 1] " If this is the first blank line, start a group else - let l:group = 1 + let group = 1 endif endfor " Delete each flagged line, in reverse order so that renumbering doesn't " bite us - for l:num in reverse(l:deletions) - silent execute l:num . 'delete' + for num in reverse(deletions) + silent execute num . 'delete' endfor " Report how many lines were deleted - echomsg len(l:deletions) . ' deleted' + echomsg len(deletions) . ' deleted' endfunction diff --git a/doc/squeeze_repeat_blanks.txt b/doc/squeeze_repeat_blanks.txt index ab2cca5..0eb4894 100644 --- a/doc/squeeze_repeat_blanks.txt +++ b/doc/squeeze_repeat_blanks.txt @@ -8,22 +8,22 @@ What constitutes a "blank" line is configurable per-buffer. REQUIREMENTS *squeeze_repeat_blanks-requirements* -This plugin is only available if 'compatible' is not set. It also requires the -|+user_commands| feature. +This plugin is only available if 'compatible' is not set. It also requires +the |+user_commands| feature. COMMANDS *squeeze_repeat_blanks-commands* *:SqueezeRepeatBlanks* Find repeated blank lines matching the |b:squeeze_repeat_blanks_blank| pattern and delete all but the last line of every such group, reporting the number of -lines removed. Accepts a range and defaults to the whole buffer. +lines removed. Accepts a range and defaults to the whole buffer. OPTIONS *squeeze_repeat_blanks-options* *b:sequeeze_repeat_blanks_blank* The |buffer-variable| `b:squeeze_repeat_blanks_blank` can be set to a pattern that constitutes a blank line, for example including whitespace, or a comment -or quoting leader. This might be desirable for some filetypes. The +or quoting leader. This might be desirable for some filetypes. The `:SqueezeRepeatBlanks` command defaults to using `^$`, for a true blank line. AUTHOR *squeeze_repeat_blanks-author* diff --git a/plugin/squeeze_repeat_blanks.vim b/plugin/squeeze_repeat_blanks.vim index dcf8b0a..fb85812 100644 --- a/plugin/squeeze_repeat_blanks.vim +++ b/plugin/squeeze_repeat_blanks.vim @@ -1,18 +1,18 @@ " " squeeze_repeat_blanks.vim: User command to reduce all groups of blank lines -" to the last line in that group, deleting the others. Good for filtering +" to the last line in that group, deleting the others. Good for filtering " plaintext mail that's been extracted from HTML. " " Author: Tom Ryder <tom@sanctum.geek.nz> " License: Same as Vim itself " -if exists('g:loaded_squeeze_repeat_blanks') || &compatible +if exists('loaded_squeeze_repeat_blanks') || &compatible finish endif if !has('user_commands') || v:version < 700 finish endif -let g:loaded_squeeze_repeat_blanks = 1 +let loaded_squeeze_repeat_blanks = 1 " User command for the above command! -range=% SqueezeRepeatBlanks |