From ac03762d0218727d97e52adadb30cf2a9f32dd26 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 24 Jul 2018 14:18:54 +1200 Subject: Add colon_operator.vim plugin --- vim/plugin/colon_operator.vim | 24 ++++++++++++++++++++++++ vim/vimrc | 3 +++ 2 files changed, 27 insertions(+) create mode 100644 vim/plugin/colon_operator.vim (limited to 'vim') 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 +" 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 (ColonOperator) + \ :set operatorfunc=ColonOperatorg@ 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 & :&& endif +" Map g: as a 'colon operator' +nmap g: (ColonOperator) + " Cycle through argument list nnoremap [a :previous nnoremap ]a :next -- cgit v1.2.3