Search code examples
xmleditorindentationgeany

Auto-correct XML indentation in Geany


My problem is auto-formatting/indenting XML in Geany, when XML is not properly indented or has no indentation at all.

As I see no Geany plugins for this purpose, I am thinking about using a custom command through Edit > Format > Send Selection To. I have tried to use xmllint --format for this without success, as it seems like Geany passes it a string, but xmllint expects a file.

  • Are there other tools for auto-indenting XML through custom Geany commands?
  • Is there another way than custom command to achieve this?

Solution

  • Found a solution. To achieve Xml indentation auto-correction in Geany (Mint/Ubuntu):

    1. Install xmlindent CLI tool:

      $ sudo apt-get install xmlindent

    2. In Geany, at Edit > Format > Send selection To > Set Custom Commands add a command:

      xmlindent -i 4 -f

    This indents lines by 4 spaces and forces newlines on elements without children.