aboutsummaryrefslogtreecommitdiff
path: root/plugin/command.vim
blob: db18cf3dc2592d78594ce1bbcb669d7916275b50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
" g: is a command to run a vim command around a text object.
"
" For example, to do a substitution inside the current block, one can do:
"
" g:iBs/foo/bar/g<cr>

noremap <silent> g: :set operatorfunc=<SID>do_command_around<cr>g@

function! s:do_command_around(str) abort
  let [_, lnum0, _, _] = getpos("'[")
  let [_, lnum1, _, _] = getpos("']")

  call feedkeys(printf(":silent! %d,%d ", lnum0, lnum1))
endfunction