aboutsummaryrefslogtreecommitdiff
path: root/autoload
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 /autoload
downloadvim-colon-operator-5525627dd9727f2ee713e3a06145a145410bcd7c.tar.gz
vim-colon-operator-5525627dd9727f2ee713e3a06145a145410bcd7c.zip
First releasev0.1.0
Diffstat (limited to 'autoload')
-rw-r--r--autoload/colon_operator.vim16
1 files changed, 16 insertions, 0 deletions
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