blob: e752e87c7f6f42ac6c603f31309f45449c5f5c89 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
"
" 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 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
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 <expr> <silent> <unique>
\ <Plug>(ColonOperator)
\ ColonMap()
|