Open Perl modules with vim
After reading about opening Perl module via name with vim, I realized it had a couple of (for me) limitations. First, I always operate from my top-level directory in a project, but that post doesn't prepend a lib/. Second, when I'm running a test suite, I see failure which might be from a module in the lib/ directory, but more often than not are in the t/lib/ directory. Since I keep all of my project directories identical, I can use one little bash function to handle this:
function vim {
set -- "${@//:://}"
module="lib/${@/%/.pm}"
testclass="t/${@/%/.pm}"
if [ -f $module ]; then
command vim $module
elif [ -f $testclass ]; then
command vim $testclass
else
command vim "${@}"
fi
}
So using it like this:
vim Veure::Foo::Bar::Baz
It will first look for lib/Veure/Foo/Bar/Baz.pm, and then look for t/lib/Veure/Foo/Bar/Baz.pm before finally giving up and just executing vim with whatever arguments I pass into it.
Improvements welcome.
another feature stolen from Padre :)
go vimers, go!
I use my Vim::Tag module to generate tags for package names, subroutine names and so on, so I can do:
You can open vim at a tag with 'vi -t', and it's easy to set up bash completion for those tags.
http://search.cpan.org/dist/Vim-Tag/lib/Vim/Tag.pm
I've had this line in my aliases file for ages now:
@Gabor: I really like the idea of Padre, I just never had it install cleanly on OS X. I'll take another look sometime.