aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim')
-rw-r--r--vim/plugin/colon_operator.vim24
-rw-r--r--vim/vimrc3
2 files changed, 27 insertions, 0 deletions
diff --git a/vim/plugin/colon_operator.vim b/vim/plugin/colon_operator.vim
new file mode 100644
index 00000000..4360e7ab
--- /dev/null
+++ b/vim/plugin/colon_operator.vim
@@ -0,0 +1,24 @@
+"
+" 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
+
+" Operator function starts typing an ex command with the operated range
+" pre-specified
+function! ColonOperator(type) abort
+ call feedkeys(':''[,'']', 'n')
+endfunction
+
+" Set up mapping
+nnoremap <Plug>(ColonOperator)
+ \ :<C-U>set operatorfunc=ColonOperator<CR>g@
diff --git a/vim/vimrc b/vim/vimrc
index cd059d28..3dadba76 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -195,6 +195,9 @@ if exists(':xnoremap')
xnoremap <silent> & :&&<CR>
endif
+" Map g: as a 'colon operator'
+nmap g: <Plug>(ColonOperator)
+
" Cycle through argument list
nnoremap [a :previous<CR>
nnoremap ]a :next<CR>