-9

How can I paste the contents of the system clipboard to all files in the argument list in Vim?

ThisSuitIsBlackNot
  • 21,870
  • 8
  • 56
  • 101

1 Answers1

2

You can do the following:

:argdo execute 'normal! "+p' | w

Explanation:

  • :argdo Run the command that follows on each file in the argument list. Alternatively, you can use :windo to run a command on each window, or :bufdo to run a command on each buffer.

  • execute "normal! ..." Run the sequence of commands after normal! as if they were entered in normal mode. Ignore all mappings and replace string escape sequences like \<esc>.

  • "+p Paste the register for the system clipboard. Note that Vim has to be compiled with the +clipboard feature enabled for this to work.

  • | w Write every file, whether it was updated or not. Alternatively, use | update to only write files that were changed.

For more details, see:

Originally answered by Roberto Balejík

Community
  • 1
  • 1
ThisSuitIsBlackNot
  • 21,870
  • 8
  • 56
  • 101