[oXygen-user] Indentation of elements but not of comments

Oxygen XML Editor Support (Adrian Buza) support at oxygenxml.com
Wed Feb 5 07:12:15 CST 2020


There is no option in Oxygen to tell the formatter to treat an XML
comment differently.
Given the small snippet that you provided, it's not possible to provide
a sure answer, because Oxygen formats an element differently depending
on its type of content (elements and/or text).

Given your description (that the line breaks before the comment), I can
only assume that your "pattern" element contains only elements
(element-only content).
    <pattern><!-- This is a comment -->
In this case, if you want to force the formatter to keep the XML comment
where it is without breaking the line, you can tell it that "pattern"
has "Mixed content" (elements and text). In Editor / Format / XML, go to
the Elements spacing > "Mixed content" tab and Add the "pattern" element
to the list.

Also note that if there is a space between the start tag and the
comment, the Oxygen formatter will consider it's fair to replace the
space with a line break.


Adrian Buza
oXygen XML Editor and Author Support

On 05.02.2020 11:16, Mike Unwalla wrote:
> Hello,
> I want to indent the elements in an XML document. Tools>Format and Indent Files lets me do this. To specify the indentation, I can use Options>Preferences>Editor/Format/XML.
> Some of the elements have comments at the end of a line. Example:
>      <pattern><!-- This is a comment -->
> I want the pattern element to be indented, but I don't want the comment on a new line. (I tried to use Elements Spacing, but I could not make it do what I want.) Is there a simple way to do what I want?
> (This e-mail message is a copy of my question on https://www.oxygenxml.com/forum/topic21114.html from 2020-01-27.)
> Mike Unwalla
> www.techscribe.co.uk
> _______________________________________________
> oXygen-user mailing list
> oXygen-user at oxygenxml.com
> https://www.oxygenxml.com/mailman/listinfo/oxygen-user

More information about the oXygen-user mailing list