2009-03-13

autoformat within padre

one of the things i care about in an editor is the ability to reformat a paragraph. it's really handy if you update your file here and there, and you're left with lines of 15 (or 100) characters.

vim has a nice builtin paragraph-reformatting tool (with gqip), and so does emacs (alt+q iirc). but padre (the perl ide) lacks one...

so i decided to create a plugin that would bring this ability to padre. moreover, it was the opportunity to discover padre's plugin subsystem.

writing the plugin was incredibly easy. especially since i'm standing on the shoulders of giants: i'm reusing the formidable text::autoformat module. in fact, adding the standard build stuff & boilerplate was really what took most of my time... ok, that and fighting a bit with wx stc, which provides everything but the methods i wanted. :-)

all in all, padre::plugin::autoformat is now propagating on cpan. to use it:
  1. install it using your favorite method
  2. open padre
  3. activate the plugin (plugins / plugin manager / autoformat / enable). you only need to do this once, since padre will remember the enabled plugins.
  4. open a file
  5. type ctrl+shift+j to autoformat either current selection (or current paragraph if nothing is selected).
enjoy it...

2 comments:

  1. Isn't that what the PerlTidy plugin already does?

    Claudio

    ReplyDelete
  2. @claudio: no, pp:perltidy works on perl files. pp:autoformat is meant to reformat text files. check text::autoformat for more information on what it can do to clean up texts.

    ReplyDelete