Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?
like image 808
atman Avatar asked Dec 01 '22 01:12

atman


1 Answers

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.

like image 155
atman Avatar answered Dec 20 '22 04:12

atman