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
:WinNT
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 ';
#!perl
#line 15
system( "vim -p ". join( ' ', map { chomp; $_ } `dir @ARGV /b`));

__END__
:endofperl

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).

Bodo
.



Relevant Pages

  • Re: Mapped vim shortcuts
    ... It used to work just fine for me too, when it was released some years ago; then came the exciting alpha versions, and later the releases, of Vim 7 with a lot of new features. ... A ":write file" command no longer resets the 'modified' flag of the buffer, ... Now only the window is closed. ... The patch was provided by Mattias Flodin. ...
    (comp.editors)
  • Re: log off command
    ... I simply execute the batch file and let them play... ... If it's by the hour you don't need a script. ... You can logoff a sessionname or a session ID in each case you have to ... Is it possible to issue the command from user1's logon to logoff ...
    (microsoft.public.windowsxp.basics)
  • Re: log off command
    ... I simply execute the batch file and let them play... ... If it's by the hour you don't need a script. ... You can logoff a sessionname or a session ID in each case you have to ... Is it possible to issue the command from user1's logon to logoff ...
    (microsoft.public.windowsxp.basics)
  • Re: [Full-disclosure] Vim: Arbitrary Code Execution in Commands: K, Control-], g]
    ... Product: Vim -- Vi IMproved ... command is assembled, and on line 5564, it is executed as a regular Ex ... No special shell escaping is done for the ``K'' command, ... Keyword Program Command Line Switches ...
    (Full-Disclosure)
  • Re: log off command
    ... SOON 3600 LOGOFF %ID2% ... If it doesn't work please post what the "at" command returns if you run it ... after the batch file and please again describe when it does not work. ... Matija Hrovat ...
    (microsoft.public.windowsxp.basics)