Auto Allman-style Braces in Komodo

komodo ide blog hero

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!

Recent Posts

Scroll to Top