From c25c045419bf818ff4a6474600e92a29f7ee7c99 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sat, 2 Jun 2018 14:54:16 +1200 Subject: Initial commit Untimely ripp'd from unimpaired.vim (essentially) and repackaged. --- README.markdown | 30 ++++++++++++++++++++++++++++++ doc/put_blank_lines.txt | 44 ++++++++++++++++++++++++++++++++++++++++++++ plugin/put_blank_lines.vim | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 README.markdown create mode 100644 doc/put_blank_lines.txt create mode 100644 plugin/put_blank_lines.vim diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..b60a433 --- /dev/null +++ b/README.markdown @@ -0,0 +1,30 @@ +put\_blank\_lines.vim +===================== + +This plugin provides mapping targets for inserting blank lines above or below +the current line without going into insert mode. The applicable code is lifted +from [unimpaired.vim][1]. It still works with [repeat.vim][2], if that's +installed, to make the mappings repeatable. + +I wrote this because I used these mappings from the original plugin frequently, +but (almost) nothing else from it. The only functional difference is that the +number of added lines is not reported, via a `:silent` suppression. + +Configuration +------------- + +To set mappings exactly like those from the original plugin, you might write +this in your `.vimrc`: + + nmap [ PutBlankLinesAbove + nmap ] PutBlankLinesBelow + +License +------- + +Copyright (c) [Tom Ryder][3]. Distributed under the same terms as Vim itself. +See `:help license`. + +[1]: https://www.vim.org/scripts/script.php?script_id=1590 +[2]: https://www.vim.org/scripts/script.php?script_id=2136 +[3]: https://sanctum.geek.nz/ diff --git a/doc/put_blank_lines.txt b/doc/put_blank_lines.txt new file mode 100644 index 0000000..b233c28 --- /dev/null +++ b/doc/put_blank_lines.txt @@ -0,0 +1,44 @@ +*put_blank_lines.txt* For Vim version 7.0 Last change: 2018 June 2 + +DESCRIPTION *put_blank_lines* + +This plugin provides mapping targets for inserting blank lines above or below +the current line without going into insert mode. The applicable code is lifted +from unimpaired.vim. It still works with repeat.vim, if that's installed, to +make the mappings repeatable. + +I wrote this because I used these mappings from the original plugin frequently, +but (almost) nothing else from it. The only functional difference is that the +number of added lines is not reported, via a `:silent` suppression. + +CONFIGURATION *put_blank_lines-configuration* + +To set mappings exactly like those from the original plugin, you might +write this in your |vimrc|: +> + nmap [ PutBlankLinesAbove + nmap ] PutBlankLinesBelow +< +REQUIREMENTS *put_blank_lines-requirements* + +This plugin is only available if 'compatible' is not set. + +MAPPINGS *put_blank_lines-mappings* + + *PutBlankLinesAbove* +The `PutBlankLinesAbove` target inserts a blank line above the current +line. Mappings through it can be prefixed with an optional count. + + *PutBlankLinesBelow* +The `PutBlankLinesBelow` target inserts a blank line below the current +line. Mappings through it can be prefixed with an optional count. + +AUTHOR *put_blank_lines-author* + +Written and maintained by Tom Ryder . + +LICENSE *put_blank_lines-license* + +Licensed for distribution under the same terms as Vim itself (see |license|). + + vim:tw=78:ts=8:ft=help:norl: diff --git a/plugin/put_blank_lines.vim b/plugin/put_blank_lines.vim new file mode 100644 index 0000000..09bb1b8 --- /dev/null +++ b/plugin/put_blank_lines.vim @@ -0,0 +1,32 @@ +" +" put_blank_lines.vim: Provide plugin maps to put blank lines above or below +" the current line. The guts of this is ripped straight out of Tim Pope's +" unimpaired.vim plugin, and still uses repeat.vim if it can find it. +" +" Author: Tom Ryder +" License: Same as Vim itself +" +if exists('g:loaded_put_blank_lines') || &compatible + finish +endif +let g:loaded_put_blank_lines = 1 + +function! s:PutBlankLinesAbove(count) + silent put! =repeat(nr2char(10), a:count) + ']+1 + silent! call repeat#set("\PutBlankLinesAbove", a:count) +endfunction + +function! s:PutBlankLinesBelow(count) + silent put =repeat(nr2char(10), a:count) + '[-1 + silent! call repeat#set("\PutBlankLinesBelow", a:count) +endfunction + +nnoremap + \ PutBlankLinesAbove + \ :call PutBlankLinesAbove(v:count1) + +nnoremap + \ PutBlankLinesBelow + \ :call PutBlankLinesBelow(v:count1) -- cgit v1.2.3