Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paste from clipboard in vim script

I want to write a vim function that includes pasting from the clipboard (windows if it matters)

I think it should be something like

function MyPastingFunc()
  "+p  "paste from clipboard
  "do more stuff
endfunction

Of course the "+p is just a comment in the .vim file. How can I make this work?

like image 861
ScottS Avatar asked Jun 30 '26 10:06

ScottS


1 Answers

You are looking for the :normal command:

function MyPastingFunc()
  "paste from clipboard
  normal! "+p
  "do more stuff
endfunction

The ! is used to prevent vim also running user mappings that might be part of "+p.

like image 112
too much php Avatar answered Jul 02 '26 01:07

too much php