From 5525627dd9727f2ee713e3a06145a145410bcd7c Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 24 Jul 2018 15:01:34 +1200 Subject: First release --- README.md | 15 +++++++++++++++ VERSION | 1 + autoload/colon_operator.vim | 16 ++++++++++++++++ doc/colon_operator.txt | 31 +++++++++++++++++++++++++++++++ plugin/colon_operator.vim | 19 +++++++++++++++++++ 5 files changed, 82 insertions(+) create mode 100644 README.md create mode 100644 VERSION create mode 100644 autoload/colon_operator.vim create mode 100644 doc/colon_operator.txt create mode 100644 plugin/colon_operator.vim diff --git a/README.md b/README.md new file mode 100644 index 0000000..1db7c95 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +colon\_operator.vim +=================== + +This plugin provides a mapping target to use an Ex command as an operator, in a +way repeatable with the `.` (dot) operator. This allows you to, for example, +`:sort` a text object like a paragraph, and then repeat it on another +paragraph. Think of it as the `:` analogue to the `!` motion. + +License +------- + +Copyright (c) [Tom Ryder][1]. Distributed under the same terms as Vim itself. +See `:help license`. + +[1]: https://sanctum.geek.nz/ diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..6e8bf73 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/autoload/colon_operator.vim b/autoload/colon_operator.vim new file mode 100644 index 0000000..04a099b --- /dev/null +++ b/autoload/colon_operator.vim @@ -0,0 +1,16 @@ +" Operator prompts for a command if it doesn't have one from a prior run, and +" then runs the command on the selected text +function! colon_operator#Operatorfunc(type) abort + if !exists('s:command') + let s:command = input('g:', '', 'command') + endif + execute 'normal! :''[,'']'.s:command."\" +endfunction + +" Clear command so that we get prompted to input it, set operator function, +" and return motions to run it +function! colon_operator#Map() abort + unlet! s:command + set operatorfunc=colon_operator#Operatorfunc + return 'g@' +endfunction diff --git a/doc/colon_operator.txt b/doc/colon_operator.txt new file mode 100644 index 0000000..4ec620b --- /dev/null +++ b/doc/colon_operator.txt @@ -0,0 +1,31 @@ +*colon_operator.txt* For Vim version 7.0 Last change: 2018 July 24 + +DESCRIPTION *colon_operator* + +This plugin provides a mapping target to use an Ex command as an operator, in +a way repeatable with the |.| (dot) operator. This allows you to, for example, +|:sort| a text object like a paragraph, and then repeat it on another +paragraph. Think of it as the |:| analogue to the |!| motion. + +REQUIREMENTS *colon_operator-requirements* + +This plugin only loads if 'compatible' is not set. + +MAPPINGS *colon_operator-mappings* + + *(ColonOperator)* +The single insert mode mapping target is |(ColonOperator)|. There is no +default key mapping; you should define one yourself in your |vimrc|. For +example: +> + nmap g: (ColonOperator) +< +AUTHOR *colon_operator-author* + +Written and maintained by Tom Ryder . + +LICENSE *colon_operator-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/colon_operator.vim b/plugin/colon_operator.vim new file mode 100644 index 0000000..ea0cc46 --- /dev/null +++ b/plugin/colon_operator.vim @@ -0,0 +1,19 @@ +" +" colon_operator.vim: Select ranges and run colon commands on them, rather +" like the ! operator but for colon commands like :sort. +" +" Author: Tom Ryder +" License: Same as Vim itself +" +if exists('g:loaded_colon_operator') || &compatible + finish +endif +if v:version < 700 + finish +endif +let g:loaded_colon_operator = 1 + +" Set up mapping +nnoremap + \ (ColonOperator) + \ colon_operator#Map() -- cgit v1.2.3