How can I paste the contents of the system clipboard to all files in the argument list in Vim?
Asked
Active
Viewed 140 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:
:argdoRun the command that follows on each file in the argument list. Alternatively, you can use:windoto run a command on each window, or:bufdoto 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>."+pPaste the register for the system clipboard. Note that Vim has to be compiled with the+clipboardfeature enabled for this to work.| wWrite every file, whether it was updated or not. Alternatively, use| updateto 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
Community
- 1
- 1
ThisSuitIsBlackNot
- 23,492
- 9
- 63
- 110