Wikia

Vim Tips Wiki

Opening several files in vim via ListFile

Talk0
1,612pages on
this wiki
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 :)

CommentsEdit

Try:

gvim -c ":args `type mylist`"

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

gvim *\2*\xx.txt

Around Wikia's network

Random Wiki