Code and Hacks

Stuff I've stumbled on or figured out... mostly Perl, Linux, Mac and Cygwin.

My Photo
Name:
Location: CA, United States

Perl hacker, investor and entrepreneur.

Tuesday, June 16, 2009

Stealing from Padre for Vim

I'm sure the Padre developers weren't hoping to have their code absconded for those of us addicted to vim, but tsee's recent blog post on refactoring with Padre's lexical variable replace made me jealous--I want that for vim! So hack, hack, hack and voila:

screenshot
This really is just leveraging the Padre code. At this point I actually use Padre::PPI but that has the downside of requiring Wx (which I personally like but it is quite a requirement). I only added a bit of code to make this into its own package and included some hints on vim scripting. The idea is to show how this could be abstracted into a standalone module then Padre, vim and any other reasonably powerful editor could use it. For now, I have packaged it as App::LexVarReplace with App::LexVarReplace::Vim pod. I would appreciate suggestions on the package layout and name, and any feedback from the Padre guys would be great. The git repository is available for your perusal. I must say that Padre seems very cool. I continue to check it out every once in a while, but I just can't seem to give up vim, gnu screen and a good old xterm. The developers have really done a great job leveraging modern Perl tools. You should check it out! I am only publishing this on github for now. I would like to speak with tsee or one of the Padre developers before this makes it debut on CPAN, but I'm a bit short on time at the moment.

Labels: ,

16 Comments:

Anonymous Anonymous said...

This is awesome!

I'd really would like that Part of Padre abstracted out to stand-alone package(s) so they can be reused by whoever wants them. Come over to #padre on irc.perl.org to discuss it.

June 17, 2009 at 12:12 AM  
Anonymous Anonymous said...

ps. Actually I was hoping for that, as I know we cannot convert the vim and emacs addicts.

And if you've done all the stealing I can go back using vim :-)

June 17, 2009 at 12:15 AM  
Blogger Unknown said...

Hi,

thanks for the praise! For the most part, we tried to keep functionality that may be useful in other contexts separate from the main distribution (cf. Wx::Perl::DataWalker, etc.). However, with the refactoring tools, I was sometimes using the Wx STC methods quite heavily for the "output" portion of the code.

It's great to see these features adopted for other tools. There is no conceptual reason not to refactor them into standalone modules that can be used without the Wx dependency. I'll check out the work you've already done when I can. Since the refactoring code is still somewhat in flux, I'd prefer to have it live in the same VCS repository as Padre (but as a separate distribution). Why don't you drop by #padre on irc.perl.org to get a commit bit from Gabor? Alternatively, feel free to write a mail to the mailing list.

Cheers,
Steffen

PS: While I use Padre more and more often for my Perl code, I'm still primarily a vim user, too. This isn't going to change either, as I mostly write C++.

June 17, 2009 at 12:25 AM  
Blogger Ahmad M. Zawawi said...

I totally love it. Simple and effective. Keep up the good work :)

June 17, 2009 at 12:33 AM  
Blogger Luc St-Louis said...

Wow, this is great! I'd been hoping for some of the Padre functionality to be integrated into Vim, and here it is. Yes, yes, keep up the good work!

June 17, 2009 at 6:47 AM  
Anonymous Anonymous said...

Woo! Now I can be the cool kid at work even though I use vim!

June 17, 2009 at 8:31 AM  
Blogger Harold Fowler said...

Cool code dude!

RT
www.anon-tools.tk

June 25, 2009 at 4:54 AM  
Anonymous Anonymous said...

Wheel remade yet again...

:1,79s/x_var/shiny/g

Way to make people dumber, guy.

June 25, 2009 at 7:52 AM  
Anonymous Anonymous said...

So Human - how does that manage to avoid replacing instances of x_var that appear in pod, strings, subroutine names etc? Is it dark magic.

It doesn't matter much with a name like x_var - but when it's called $interface, your pod talks extensively about interfaces and you want to change it to $trait then it matters.

And if you're going to use global s/r you should at least restrict the search pattern thusly

\<x_var\>

to avoid substring collisions.

June 25, 2009 at 8:04 AM  
Anonymous Anonymous said...

Oh and

"Way to make people dumber, guy."

In your case one doubts that the risk is great.

June 25, 2009 at 8:12 AM  
Anonymous Anonymous said...

Wonderful :-) I'll try it out later.

June 25, 2009 at 8:18 AM  
Blogger Unknown said...

Wow!, It's great to get benefits of the great work the ppl is doing with padre for as, the vim's ols zealots :)

June 25, 2009 at 9:47 AM  
Anonymous Anonymous said...

My bad, you didn't have any (sub)strings there to "collide" with. Lets school 20 year veterans shall we?

Kids.

June 25, 2009 at 11:15 AM  
Blogger Unknown said...

Ah, 20 year veteran... that explains it! I seem to recall an old saying about old dogs and new tricks.

:-P

June 25, 2009 at 3:11 PM  
Blogger vishnu said...

This comment has been removed by a blog administrator.

June 27, 2009 at 7:38 AM  
Blogger Unknown said...

This comment has been removed by a blog administrator.

November 28, 2009 at 7:56 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home