Auto compress files on save

My team has a conflict on coding styles.





This may seem trivial but is important. I was wondering if anyone had seen or heard of anyone building a pluggin for komodo that would on save/ close of a file automatically minify/ indent to desired style the file in question. When any developer opened the said file komodo would automatically indent the file according to the developers preference and file type.

This would save hours of time when in both discussion and when inheriting work where indentation has followed multiple styles over the years.


A macro that would perform such actions on save would be a bit error-prone imo, you want to enforce these coding standards with your team rather than have some automated tool try and transform your code after the facts.

That said I did write a macro a while ago that your team could install to help enforce this coding style, I blogged about it here:

@nathanr, If Komodo 9 based on Mozilla 31, I think you can include feature from Mozilla Debugger: "Nice" sources to fix ugly code or fix all braces to one style. If you have a time, I recommend view this feature and how it works in source code of Mozilla.

Again I think this is potentially destructive to your code to do this automatically. We do have a “formatting” feature in your editor context menu that you can use, but this is a manual task (as it should be). If you want to automate code beautifying on save you’re of course more than free to implement a macro for this yourself but I don’t think this is something we should be offering as a native feature as it is error prone.

What errors is this prone too?

I appreciate that with a team in combination with source control this could potentially be hazardous. Indicating that possibly a pre commit hook might be the solution?

It is error prone in that running any tool that modifies your code automatically without user interference can cause serious destruction to your codebase, bugs is one example but you might also have use-cases where having your code beautified is not desirable. I would not advice anyone to run such a tool on an automated basis, especially not as a pre-commit hook, you stand the chance of loosing your modifications. If you do want to run it in an automated way I’d recommend doing a post-commit hook and committing the “beautified changes” separately.

In any case this is not something that Komodo will be automating, you can do it manually through the “formatting” menu though.

If you do decide to implement this for yourself there is a big variety of tools out there to help you do the job; just google “languagename code beautifier”.

Thanks for the tips, very much appreciated.


Did Komodo 9 has this feature? I can’t find it :expressionless:

Right click in editor > Format

This is an IDE feature, it’s not in Komodo Edit.

Or you already has Komodo Edit 9 build? :smile:

I don’t follow. It’s an IDE feature since before Komodo 9. We did not take it out for Komodo 9 so if you are running Komodo IDE 9 you should have a “format” entry in your editor context menu.

1 Like