Search code examples
textmatetextmatebundles

How do I make a TextMate macro to open all files in my project that match a regular expression?


How do I make a TextMate macro to open all files in my project that match the regular expression, "/todolist/i"?


Solution

  • I solved this in perl, by creating a command. It requires to have a file in the project already open in order for the hotkey to work. Perhaps there is no way around this, since while a file is not open in the project, the command is greyed out in the Bundle menu. Maybe there's a hotkey to open some file in the project (or some other way to get the command un-greyed)? I'd like to just press a sequence of hotkeys.

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use File::Basename;
    use File::Find;
    
    my $dir = dirname($ENV{'TM_DIRECTORY'});
    my $textmate_path = $ENV{'TM_SUPPORT_PATH'} . '/bin/mate';
    find(sub { system(qw/mate/, $File::Find::name) if /TODOLIST/ }, $dir);
    die;