diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-24 14:47:16 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-24 14:47:16 +1200 |
commit | 26cb1cbb6f38ab476e6666a7806b55a469236d90 (patch) | |
tree | dcc2ed589a8858ea1d86f97f4f30eb0a359a45f0 /vim | |
parent | Add colon_operator.vim plugin (diff) | |
download | dotfiles-26cb1cbb6f38ab476e6666a7806b55a469236d90.tar.gz dotfiles-26cb1cbb6f38ab476e6666a7806b55a469236d90.zip |
Improved colon_operator.vim plugin
Diffstat (limited to 'vim')
-rw-r--r-- | vim/plugin/colon_operator.vim | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/vim/plugin/colon_operator.vim b/vim/plugin/colon_operator.vim index 4360e7ab..e752e87c 100644 --- a/vim/plugin/colon_operator.vim +++ b/vim/plugin/colon_operator.vim @@ -13,12 +13,24 @@ if v:version < 700 endif let g:loaded_colon_operator = 1 -" Operator function starts typing an ex command with the operated range -" pre-specified +" 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! ColonOperator(type) abort - call feedkeys(':''[,'']', 'n') + 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! ColonMap() abort + unlet! s:command + set operatorfunc=ColonOperator + return 'g@' endfunction " Set up mapping -nnoremap <Plug>(ColonOperator) - \ :<C-U>set operatorfunc=ColonOperator<CR>g@ +nnoremap <expr> <silent> <unique> + \ <Plug>(ColonOperator) + \ ColonMap() |