Removing trailing blanks

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by László Mohácsi
Avatar
Is there any option to remove trailing blanks (whitespace) from
lines automatically ? (I sometimes end up having twenty spaces
at the end of lines, which make editing a bit more difficult)

If there is no such option what would be the recommended way
to remove the whitespace ?

Comments (6)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
This is something we'd like to implement for v4.0 if possible. If you have any ideas on how you'd like to see it implemented, please post them.

One problem I see without looking into it yet is that modifying the document to remove characters is an undoable modification meaning it would show up in the undo stack. But it probably shouldn't. And if we didn't add it to the stack (the way it currently is designed) then the other undo items before it would become corrupted because their offsets would be wrong.

We're open to any ideas.


Actipro Software Support

Posted 18 years ago by Rick - Developer, Visual Software Systems LLC
Avatar
I really like the idea of this feature. I understand your design concern, but I don't see that as a problem at all. In fact, I think that is a good thing as it gives the end-user the option to revert the document back to it's original state. I could see this feature working similarly to the way Microsoft treats its auto-correction feature in the Office suite -- if a change is made to a document by the application on behalf of the user, a visual indicator of the change is placed next to the change. If the user clicks on the indicator, a dropdown menu appears, giving the user the option to keep the change, revert the change, or whatever else is appropriate for the given situation. The change also appears in the undo/redo menus.
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I like the idea of the future too, just need to iron out implementation details. I don't see that Visual Studio has anything like this. Has anyone else seen it?

How do other editor applications do it? Do they have a command that the end user kicks off that works either on the entire document or on a selection only?

As far as performing live updates as the end user types, I only wonder if that would get annoying with the editor adding all kinds of single line remove-trailing-whitespace entries into the undo stack.

Or perhaps we implement it a couple ways:
1) Add a command that does it by end user request.
2) Have an option to automatically do it whenever the Document.Text property is set or a paste occurs.

If we stick to those two things, it's less of an invasive feature.

What is everyone's opinion on this?


Actipro Software Support

Posted 18 years ago by Marianne
Avatar
I'd vote for a method called TrimTrailingSpace() with an override to TrimTrailingSpace(int linenumber)

So if someone wanted to do it after every line move they could use the line number override with the Selection_Changed event if the line number has changed, they could call it for the previous line automatically. Others could use the first function before a save or at some point like when the code window is being closed so that it isn't invasive at all while you're working on some code but the next time you open it all the lines have been properly trimmed.

------------------------------- Marianne

Posted 18 years ago by Rick - Developer, Visual Software Systems LLC
Avatar
Either way is fine. Just need to ensure there is a programatic way to to the feature on/off.
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The v4.0 code now has multiple ways to trim trailing whitespace: from the entire document, a view's selection, or a certain document line. In addition a command has been added that can be bound to a key to do the selection trimming, or for the current line if there is no selection.


Actipro Software Support

The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.