Re: vim: loading in subdirectories

Tim Roberts wrote:
"Benjamin Esham" <bdesham@xxxxxxxxx> wrote:
As usual ;-) Seriously, though... I'm not at all familiar with XP's
command-line syntax, but have you tried

vim *.js */*.js

Does XP support that use of wildcards?

The Windows shells don't do anything with wildcards, which surprises some
people. The program sees exactly what you type on the command line. That
is, argv[1] is "*.js" and argv[2] is "*/*.js".

However, most programs, and especially programs ported from Unix, include
wildcard expansion routines. Your vim command does what you would expect.

However, that only goes one level deep, and it wasn't clear whether that
was enough for the OP.

OK, my final solution I'm currently working with are .bat files I'm now using to start up vim. They rely on the fact that winXP's "dir"-command can use wildcards on filenames and has a /s - switch making it recurse into subdirectories, in addition the /b - switch is needed to get just the list of filenames without any additional noise. So the steps required are as follows

1. create A perl script with this line:

system( "vim -p ". join( ' ', map { chomp; $_ } `dir @ARGV /b`));

2. Convert it to a windows batch file with the pl2bat utility which comes with the ActivePerl distribution. The result looks like this:

@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
perl -x -S %0 %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';
#line 15
system( "vim -p ". join( ' ', map { chomp; $_ } `dir @ARGV /b`));


3. Place this batch file (i called it startvim.bat) somewhere into your PATH

Now vim can be started up saying

startvim *.js

(works like vim *.js) or

startvim .*js /s

which loads all *.js files from *all* subdirectories (which may be a caveat).