Trailing space on empty lines

Having trouble installing Oxygen? Got a bug to report? Post it all here.
misty
Posts: 16
Joined: Tue Feb 03, 2015 3:23 am

Trailing space on empty lines

Post by misty »

In text mode (I haven't confirmed in Author mode), if I am indented and want to create a new blank line, the blank line has trailing spaces matching my indent level. I am able to turn this off by turning off Smart Indent, but then I have to manually indent after each carriage return. I have looked everywhere and can't seem to find a way (in Oxygen) to get rid of these trailing spaces. Format and Indent is not an option, because we are using Git, and need to avoid making unnecessary changes to the file. We can probably take care of this in a pre-commit hook, but I'm hoping there is some way to take care of it in Oxygen.

Let me include some code to demonstrate what I mean:
Desired Outcome:

Code: Select all

		<p>Indented several tabstops.</p>

<p>And a new paragraph.</p>
Actual Outcome:

Code: Select all

		<p>Indented several tabstops.</p>

<p>And a new paragraph.</p>
The difference won't be obvious unless you select each code block with your mouse, then you can see the extra spaces in the empty line. This is not a huge problem but it's bad form when using Git or SVN.
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Trailing space on empty lines

Post by adrian »

Hi,

There is no option in Oxygen to automatically remove indents from empty lines.
I've logged a feature request for this.

Other than wasting a few bytes on the indents from the empty lines, I don't see a real consequence of this aspect.
If you feel the need to remove all spaces/indents from empty lines, you can use the Find/Replace dialog or Find/Replace in Files with:
Text to find: ^ +$
Replace with: (leave empty)
[x] Regular expression

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
misty
Posts: 16
Joined: Tue Feb 03, 2015 3:23 am

Re: Trailing space on empty lines

Post by misty »

Thanks for your reply. In the meantime, I have added the following client-side pre-commit hook to my Git repo:

Code: Select all


# fix trailing whitespace
for file in `git diff-index --check --cached $against -- | grep '^[^+-]' | grep -o '^.*[0-9]\+:'` ; do
file_name=`echo ${file} | awk -F ':' {'print $1'}`
line_number=`echo ${file} | awk -F ':' {'print $2'}`
# I think the reason there are two sed commands here
# is that 'sed -i' is different on different systems.
# shoot me.
sed -i '' -E "${line_number}s/[ ]*$//" "${file_name}"
git add ${file_name}
echo "Re-wrote ${file_name} to trim whitespace."
done
Post Reply