Auto Allman-style Braces in Komodo

Macro Monday – a new macro to dig into every Monday!

Komodo does not dictate any sort of coding style, it merely facilitates you to
code whichever way you want. It’s easy to code in Allman style, but we can make
it even easier with a simple macro.

Essentially what this macro does is turn;


into

Typing speed aside in these gifs, the productivity gain here is one less keypress.
It won’t make a huge difference but it’s the little things that make you more
productive.

In case it’s not clear what is happening in those gifs, normally when you would
want to write in allman step you would essentially go through the following steps


while (0)
{


The second I type the opening brace Komodo auto completes it to


while (0)
{|}


Where “|” represents the cursor. Then when I press enter I get:


while (0)
{
|
}


This works great, but we can make it even shorter (without resorting to snippets), what if I could just write the following


while (0) {


And the second I type the opening brace it auto-completes to Allman style indentation?
That is basically what this macro does.

Currently this macro is still very experimental and will likely have a few bugs
that need to be worked out. Hopefully we’ll be able to include it as a native
feature in Komodo 9.

Installation

To install the macro simply hit the “View Resource” and “Install Instructions”
links below. You’ll want to hook the macro up to the “On Startup” trigger.

 

Usage

Simply start typing! Provided that you have triggered the macro (either via the
startup event or by manually invoking it) it will automatically complete your
curly braces to Allman style.

Credits

Thanks to @woodpile from the Komodo Forums for pointing out the use-case for this functionality!

Nathan Rijksen

Nathan Rijksen

Nathan Rijksen is the Development Lead for Komodo IDE. He works adeptly with Mozilla, Python and JavaScript to ensure that Komodo IDE is the IDE of choice for development teams. Nathan has been working with Komodo IDE for a decade before joining the development team in 2012. Since then he has worked tirelessly on new features such as Commando, Breadcrumbs, a completely new UI and much more.