How can I paste the contents of the system clipboard to all files in the argument list in Vim?
Asked
Active
Viewed 137 times
-9
-
5Is there a question in here? – FDinoff Apr 04 '15 at 16:07
-
I wanna do Q/A style but I had it already written - why can't I write it in 1 post like first the the question and then the answer? – Roberto Balejík Apr 09 '15 at 16:01
1 Answers
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 afternormal!
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:
- Learn Vimscript the Hard Way
- Vim 101: Search and Replace on Multiple Files
- Run a command in multiple buffers
Originally answered by Roberto Balejík
![](../../users/profiles/-1.webp)
Community
- 1
- 1
![](../../users/profiles/176646.webp)
ThisSuitIsBlackNot
- 21,870
- 8
- 56
- 101