Here's a little script I cooked up manage opening all the files in a given project in one gVim session at once.

This script will scan the current directory and any subdirectories for files with matching extensions, and then send the lot to gVim for editing.

Invoke the script with a list of extensions to open. For example:

vitree.pl pl pm t
is a nice way to open the files in a perl project.

The script is win32 only. So if you are working on a real computer, you'll have to switch the create process call to 'system'.

# ViTree use warnings; use strict; use File::Find; use Win32::Process; use Time::HiRes qw(sleep); # get set of extensions to work with. my %extensions; @extensions{ @ARGV } = (); # Come up with a more or less unique gVim server name. my $seed = int( rand 1000 ); my $servername = GetServerName( $seed ); # Build a list of files to open. my @files; find( \&MatchFiles, '.' ); exit unless @files; # and open them. my $counter = 0; print "Opening files:\n"; foreach my $file ( @files ) { print "$counter\t$file\n"; my $ProcessObj; # I was using system(1,blah blah) but that maxed out at 64 files. # Process::Create seems to handle anything I throw at it. Win32::Process::Create( $ProcessObj, "C:/WINDOWS/gvim.BAT", qq(gvim --servername $servername --remote-silent "$file"), 0, NORMAL_PRIORITY_CLASS, "." ) || die ErrorReport(); # Waiting for a bit keeps files from disappearing. # Also prevents "Application failed to initialize" errors. if ( $counter++ ) { sleep(0.1); } else { # need to wait longer at the first invocation # otherwise we sometimes miss a file or two. sleep(1); } } # the "wanted" function for File::Find sub MatchFiles { no warnings 'uninitialized'; /\.(\w*)$/; my $ext = $1; return unless length $ext; push @files, $File::Find::name if exists $extensions{$ext}; } # I broke this out earlier when # I thought I needed to spawn # multiple gVim servers to work # around a limit in gVim. # # The problem is with windows, and # the work around is different, but # I never put this back. Damn lazy. sub GetServerName { my $seed = shift; my $time = time; return "$seed-$time"; } # Copied straight from the Win32::Process docs. sub ErrorReport { print Win32::FormatMessage( Win32::GetLastError() ); }


TGI says moo