문제

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?
도움이 되었습니까?

해결책

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.

다른 팁

The is also the (XML) pretty printer plugin avaialble redoing indention of an xml document and some more function.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top