1
function! OperatorFunc(type, ...)

  " how to call another operator with current motion?

  " do other stuff

endfunction

Is it possible to get motion text? such as get iw from yiw

1 Answer 1

1

Visually select motion text, execute existing operator:

function! OperatorFunc(type, ...)

  " change op to desired operator
  call ExecuteOperator(a:type, a:0 > 0, 'op')

  " do other stuff

endfunction

function! ExecuteOperator(type, visual, operator)
  if a:visual
    exe 'norm gv'.a:operator
  els
    exe printf('`[%s`]%s', a:type ==# 'line' ? 'V' : 'v', a:operator)
  endif
endfunction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.