Vim Tips Wiki

Opening several files in vim via ListFile

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 557 Printable Monobook Previous Next

created September 16, 2003 · complexity intermediate · author Alex J. · version 5.7

Suppose you want to open several files in Vim, but the names of the files to open are stored in a file, each file name on separate line. This is the case with Total Commander, when you open a program and pass %L as a parameter.

It is possible to do it like this:

gvim "+gl/^/exec 'badd '.getline('.')" +bdel +nohls +"cd %:h" LISTFILE

where LISTFILE contains the list of file names to open.

Using Total Commander, I create new item in "start menu", and assign a shortcut, let's say CTRL+ALT+F4 to it. Set path\gvim.exe as a command.

This is what i put in a "parameters" section:

"+gl/^/exec 'badd '.getline('.')" +bdel +nohls +"cd %%:h" %L

Then I can select several files, press CTRL+ALT+F4 and load all of them into my favourite text editor :)



gvim -c ":args `type mylist`"

You can also use commands like the following, even on Windows:

gvim *\2*\xx.txt

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.