Вопрос

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