9

I have a function which takes a string of commands to execute and makes sure 'paste' is on before it runs them. What I'm looking for is akin to the following:

vmap <silent> <C-K> :<C-U>call InPasteMode("<Plug>ReplaceVisual")<CR>
function! InPasteMode(command)
  let oldpaste = &l:paste
  try
    set paste
    execute "normal" a:command
  finally
    let &l:paste = oldpaste
  endtry
endfunction

but the command, "<Plug>ReplaceVisual", needs to run in Visual mode, not Normal mode.

Is there a command like :normal which runs keystrokes in Visual mode?

1 Answer 1

14

gv restores the last visual selection. So, something like execute "normal gv" . a:command should work.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.