aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-24 15:01:34 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-24 15:01:34 +1200
commit5525627dd9727f2ee713e3a06145a145410bcd7c (patch)
treea9d8df829874a503a6726ccf6fda3db8e00f9d28
downloadvim-colon-operator-5525627dd9727f2ee713e3a06145a145410bcd7c.tar.gz
vim-colon-operator-5525627dd9727f2ee713e3a06145a145410bcd7c.zip
First releasev0.1.0
-rw-r--r--README.md15
-rw-r--r--VERSION1
-rw-r--r--autoload/colon_operator.vim16
-rw-r--r--doc/colon_operator.txt31
-rw-r--r--plugin/colon_operator.vim19
5 files changed, 82 insertions, 0 deletions
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."\<CR>"
+endfunction
+
+" Clear command so that we get prompted to input it, set operator function,
+" and return <expr> 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*
+
+ *<Plug>(ColonOperator)*
+The single insert mode mapping target is |<Plug>(ColonOperator)|. There is no
+default key mapping; you should define one yourself in your |vimrc|. For
+example:
+>
+ nmap g: <Plug>(ColonOperator)
+<
+AUTHOR *colon_operator-author*
+
+Written and maintained by Tom Ryder <tom@sanctum.geek.nz>.
+
+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 <tom@sanctum.geek.nz>
+" 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 <expr> <silent> <unique>
+ \ <Plug>(ColonOperator)
+ \ colon_operator#Map()