aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-24 14:18:54 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-24 14:18:54 +1200
commitac03762d0218727d97e52adadb30cf2a9f32dd26 (patch)
treedd4a4af46ebb2dc94cd23517fa8cbef983cef581 /vim
parentMove quickfix auto-open into a little plugin file (diff)
downloaddotfiles-ac03762d0218727d97e52adadb30cf2a9f32dd26.tar.gz
dotfiles-ac03762d0218727d97e52adadb30cf2a9f32dd26.zip
Add colon_operator.vim plugin
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>