Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smart auto-indentation available in geany?

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?

like image 950
Connor Leech Avatar asked Sep 16 '13 12:09

Connor Leech


2 Answers

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

like image 69
Tobiasz Avatar answered Sep 24 '22 12:09

Tobiasz


command for html simple smart indentation that finaly work in geany :

bash -c "tidy --indent auto --indent-spaces 2 --char-encoding utf8 --quiet yes 2>/dev/null; true" 
like image 29
Francky Avatar answered Sep 24 '22 12:09

Francky