Setting up a new Komodo IDE formatter

Posted by toddw on 2009-05-28 09:09
Question: 

How do I create a new Komodo code formatter for a given language?

Answer: 

Komodo's code formatting system can be used to launch external code formatting applications on your source code.

  • Go to Komodo's formatter preferences
    You can use Komodo's Edit->Preferences to bring up the Komodo preferences dialog, then select the Formatters category.
  • Create new formatter
    Use the green (+) button to start creating a new formatter. Fill in the Name and Language fields and then in the Formatter menu select the Other Formatters->Generic command-line formatter. This will show further configurable options to customize the formatter command. Generally this will be the name of the executable (example "tidy") and the options that are passed to this executable. The actual code to be formatted will be passed via stdin.
  • Example Language Formatters

guthrie | Thu, 2009-05-28 10:53

This is great! thanks.

coolluar | Wed, 2009-09-23 21:50

my komodo version and linux platform given below....

Komodo Edit, version 5.2.0, build 4075, platform linux-libcpp6-x86.
Built on Fri Sep 11 19:09:24 2009.

please help me get this formatter.

it will be of really great help to format those old junky codes in our server..

toddw
ActiveState Staff
Thu, 2009-09-24 09:17

The built-in Komodo code formatters are only available in Komodo IDE, though there are some alternatives when using Komodo edit, see this post for details:
http://community.activestate.com/forum/code-formatting-0#comment-10346

Cheers,
Todd

lado | Tue, 2009-12-01 04:27

I followed the faq instructions to add a formatter to IDE (Perl Tidy in this case), but the new formatter does not even appear in the formatter menu choices.

I think that it'd be very nice AS give us a working 'howto' for adding the Perl Tidy. I should hope that Perl editing/debugging is important enough so AS finally take steps to integrate Perl code formater to the IDE ?!

Btw, I've tried some scripts (macros) which I found on forums for using the Perl Tidy, but I wasn't quite satisfied with that.

Regards, Vladimir

lado | Tue, 2009-12-01 05:13

Uhh, after restarting the Komodo IDE, I got the menu choice for Perl formatter.

However, It does not work, because I don't know how can I pass the script content to the formater. I was trying different things, but the IDE yells at me: IOError:[Errno 32] Broken Pipe.

I was browsing through FAQ's and Forums but found no suggestions ...

Regards, Vladimir

nijikon | Fri, 2010-06-11 15:24

Can I bind a new formatter to a key?

toddw
ActiveState Staff
Fri, 2010-06-11 15:55

You can go into Komodo's "Editor->Key Bindings" preferences and search for "Format Code", then assign any keybinding you wish (the default is Ctrl+K, Ctrl+F).

Cheers,
Todd

nijikon | Fri, 2010-06-11 23:05

"(Ctrl+K, Ctrl+F) is not a valid key sequence".

Komodo IDE, version 5.2.4, build 37659, platform macosx-x86.
Built on Tue Dec 8 18:18:47 2009.

toddw
ActiveState Staff
Sat, 2010-06-12 10:07

Ack - my mistake. There is no default keybinding assigned to the format command, Ctrl+K, Ctrl+F is the keybinding I assigned in my own Komodo preferences for this command. Sorry for the confusion there - just add your own keybinding as you prefer.

Cheers,
Todd

nijikon | Sat, 2010-06-12 11:09

No worries, Ctrl+K, Ctrl+F just became my default code format binding, thanks!

sree | Sat, 2010-11-20 22:47

I have been looking all over the internet on how to set up the Komodo IDE formatter and I really did not know where to search for it. The search results that returned were all dealing with the old ones and I was not sure whether I should continue because that may sometimes stall my actions after all! Hence I searched over and over until I ended here and I have to say I am so happy that I did! I followed the steps even though it was a little confusing at first and I ended in getting the job done

Sree

-E
cgchoffman
ActiveState Staff
Thu, 2011-12-08 10:27

If you get the Tokenize error you can alos add -E after the path/to/reindent.py:

path/to/reindent.py -E