I have several file paths saved in a register. I would like to open them all into the same new buffer. (as if I ran
cat * files | vim - from command line.
As this is part of a plugin, I would like to do this all with vim script.
:read command reads a file into the current buffer; although it only works for one file. You'll need to add a new command which calls
:read in a loop:
command! -nargs=+ -complete=file Read
\ for f in [<f-args>]
\| exe ':$read ' f
You need the
$ range in read to tell it to append the file to the end of the buffer; by default the cursor stays in place, so the files will get intermixed.
You can also call
glob() if you want to accept things such as
*.vim; I added support for this in my little globedit.vim plugin.