aboutsummaryrefslogtreecommitdiff
path: root/autoload/colon_operator.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/colon_operator.vim')
-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