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?
To get into the Vim Visual Line mode, press “Shift+V” while you are in Vim's Normal mode.
Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement. Press d (delete) to cut, or y (yank) to copy.
Entering visual mode from insert mode In insert mode, you can execute a normal mode command with Ctrl-o . While you are in this normal-mode-ready, run visual mode key v . If you notice, on the bottom left, it will say --(insert) VISUAL-- .
gv
restores the last visual selection. So, something like execute "normal gv" . a:command
should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With