Smart auto-indentation available in geany?

Connor Leech picture Connor Leech · Sep 16, 2013 · Viewed 23.7k times · Source

I'm writing javascript using Geany IDE. My indentation is all messed up and I'd like to make it look nice. When I write Java in Eclipse I can do ctrl + i to make all the spacing in order.

What is the indentation option available in Geany?

Answer

Tobiasz picture Tobiasz · Sep 30, 2013

The document formatting option is on the Geany's plugin wishlist (ref. Auto Correct Indentation section in Geany's Plugin Wishlist).

However, Geany allows to send text using custom commands.

As you may suspect this opens a pretty wide selection of new "doors" behind which lies the solution of your problem, e.g. Artistic Style is a cross-platform code auto-formatter for C, C++, C#, and Java. So the solution is:

  • get a copy of any code formatting tool that accepts text from standard input and returns the resulting text to standard output,
  • in Geany go to Send Selection to->Set Custom Commands and add an appropriate command for your tool

I am not an agitator for Artistic Style, you can just use any tool that formats Java code. It has been done this way with HTML Tidy or PHP Beautifier, results look like this:

enter image description here