Vim Filters: Transforming Java to Perl

by Curtis Poe

Vim is incredibly powerful, but it has the downside of a steep learning curve. Once that is surmounted, however, it's easy to do a lot of powerful tricks with it. Many of these are things that one sees in full-blown IDEs. My setup provides auto-completion, test suite management, build management, source control integration and a variety of other useful tricks. One of the things that I really appreciate about vim is its handy filtering ability, but most vim developers don't seem to be aware of it. I'll explain one way of using it, with a primitive java2perl filter.


4 Comments

Amazed
2008-04-16 00:42:11
Cool! Do you give 6 weeks quick intro classes in software development using perl and wim? I want a seat!!


Keep up the good work,
cheers

Matthew
2008-04-18 02:36:09
Excellent, but would it be worth filtering the modifiers for the method in a more resilient way? Ultimately you discard them, so you could change:


my $access_level = qr/public|private|protected/;
...
$access_level
\s+
(?:static\s+)?


Into something like:


my $access_and_modifiers = qr/public|protected|private|static|final|synchronized|strictfp/;
...
(?:$access_and_modifiers\s+)*


That way, the order of the modifiers and access level tokens does not matter, and it also accommodates the situation where no access level has been specified (default access). I may have missed a method appropriate modifier, but you get the idea.


Bit pedantic though :)

Ovid
2008-04-18 03:46:00
@Matthew: what you write sounds reasonable. To be fair, it's been a few years since I did serious Java programming and I know that my approach was rather limited. I'm happy with an 80% solution, but I'd be happy to see a more serious approach here.
eduardo
2008-04-29 11:28:41
I like it, i hope we can see something like this on GNOME so you can code in MONO and then just translate to "C" an get all the power. Have you ever seen Valac?