0

The workflow Id like is as follows

  • Im in insert mode
  • I paste using Command + V
  • The text is pasted
  • Normal mode is initiated

Currently I remain in insert mode afterwards

Daniel Kobe
  • 9,376
  • 15
  • 62
  • 109
  • The problem here is getting the system clipboard to play nicely with vimscript. Maybe [this post](https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim) can help you get closer to that? – wxz Mar 30 '21 at 19:55
  • Here is a better workflow: stay in normal mode and use Vim's built-in clipboard support: `"+p`. – romainl Mar 30 '21 at 20:21

1 Answers1

0

It's not recommended that you use cmd+v for pasting but here is the solution. Remap your key like this and your register to whatever you use. Position your cursor however you want in the function.

function! LeaveInsert() abort
exe "normal! ".'"'."+p "
call feedkeys("\<Esc>")
endfunction

inoremap <c-v>  <Cmd> :call LeaveInsert()<cr>
ritchie
  • 405
  • 1
  • 4
  • 12