Disable adding newline at the end of file and auto line break when long line? Keep the original type of spacing?

Questions about XML that are not covered by the other forums should go here.
tanquang
Posts: 7
Joined: Wed Apr 28, 2021 10:41 pm

Disable adding newline at the end of file and auto line break when long line? Keep the original type of spacing?

Post by tanquang » Wed Apr 28, 2021 10:54 pm

I have a problem with the Format and Indent Files (Pretty-Print) tool.
Specifically: After using the tool, my XML file automatically generated a blank line at the end of the file. The long lines are all truncated to multiple lines (quite difficult to read). All spacing (tabs, spacing) are replaced with spaces.
So I want to ask: How to disable adding newline at the end of file and auto line break when long line? Keep the original type of spacing?

tavy
Posts: 284
Joined: Thu Jul 01, 2004 12:29 pm

Re: Disable adding newline at the end of file and auto line break when long line? Keep the original type of spacing?

Post by tavy » Thu Apr 29, 2021 12:30 pm

Hello,

Thanks for your feedback.
You can control the formatting opinions from "Options->Preferences-> Editor / Format" options page.
The number of characters after which the Format and Indent (pretty-print) action performs hard line-wrapping, is by default 100. You can set a different value from the "Line width" option. You can also enable "Detect line width on open" option, and Oxygen will automatically detect the line width when the document is opened. This is useful when you have multiple long lines, if just some of the lines are long, you must manually set a value in the "Line width" option.
If your document is indented with tabs, please make sure that the option "Detect indent on open" is selected (by default is selected). If this option is selected Oxygen will detect when TAB characters are used to indent content, and the size of the TAB characters is used for the indent size.
You can also force a document to be indented with tabs by selecting "Indent with tabs." option.
Unfortunately, the the new line added at the end of document cannot be controlled. The Format and Indent action always adds a new line, if there is not already a new line there.

You can find more details about formatting options in our user manual:
https://www.oxygenxml.com/doc/versions/ ... ormat.html

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

tanquang
Posts: 7
Joined: Wed Apr 28, 2021 10:41 pm

Re: Disable adding newline at the end of file and auto line break when long line? Keep the original type of spacing?

Post by tanquang » Thu Apr 29, 2021 6:42 pm

tavy wrote:
Thu Apr 29, 2021 12:30 pm
Hello,

Thanks for your feedback.
You can control the formatting opinions from "Options->Preferences-> Editor / Format" options page.
The number of characters after which the Format and Indent (pretty-print) action performs hard line-wrapping, is by default 100. You can set a different value from the "Line width" option. You can also enable "Detect line width on open" option, and Oxygen will automatically detect the line width when the document is opened. This is useful when you have multiple long lines, if just some of the lines are long, you must manually set a value in the "Line width" option.
If your document is indented with tabs, please make sure that the option "Detect indent on open" is selected (by default is selected). If this option is selected Oxygen will detect when TAB characters are used to indent content, and the size of the TAB characters is used for the indent size.
You can also force a document to be indented with tabs by selecting "Indent with tabs." option.
Unfortunately, the the new line added at the end of document cannot be controlled. The Format and Indent action always adds a new line, if there is not already a new line there.

You can find more details about formatting options in our user manual:
https://www.oxygenxml.com/doc/versions/ ... ormat.html

Best Regards,
Octavian
Hello,
How do I customize the end of lines (Windows, Unix, ...) of the file?
My problem is that the tool replaced all spaces (tabs, spaces) of the value in the XML tag with spaces. For example:
Before formatting:

Code: Select all

<ms0>		1			#		340028		#		5		</ms0>	<ms1>		1500		#		340028		#		150		</ms1>
After format (all TAB spaces have been replaced with spaces):

Code: Select all

		<ms0> 1 # 340028 # 5 </ms0>
		<ms1> 1500 # 340028 # 150 </ms1>
I want to keep the original spacing type included in the tag instead of replacing it with such spacing:

Code: Select all

		<ms0>	1		#	340028		#	5	</ms0>
		<ms1>	1500		#	340028		#	150	</ms1>
How to configure that gap replacement?

tavy
Posts: 284
Joined: Thu Jul 01, 2004 12:29 pm

Re: Disable adding newline at the end of file and auto line break when long line? Keep the original type of spacing?

Post by tavy » Tue May 04, 2021 8:59 am

Hello,

I think you can use the "Preserve text as it is" option from Options->Preferences->Editor / Format / XML option page. If is selected, the Format and Indent operation preserves text content as it is, without removing or adding any white space.
Another solution is to add the elements, that you want to preserve the spacing for, in the "Element Spacing Section". This section controls how the application handles whitespaces found in XML content. You can Add or Remove element names or simplified XPath expressions in the various tabs.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

tanquang
Posts: 7
Joined: Wed Apr 28, 2021 10:41 pm

Re: Disable adding newline at the end of file and auto line break when long line? Keep the original type of spacing?

Post by tanquang » Tue May 04, 2021 9:29 am

tavy wrote:
Tue May 04, 2021 8:59 am
Hello,

I think you can use the "Preserve text as it is" option from Options->Preferences->Editor / Format / XML option page. If is selected, the Format and Indent operation preserves text content as it is, without removing or adding any white space.
Another solution is to add the elements, that you want to preserve the spacing for, in the "Element Spacing Section". This section controls how the application handles whitespaces found in XML content. You can Add or Remove element names or simplified XPath expressions in the various tabs.

Best Regards,
Octavian
OK, thank you so much.

Post Reply