Remove trailing whitespace, but not from the current line


The “Strip Trailing Whitespace on Save” setting is great - but it would be nice if it didn’t strip the whitespace from the line that the cursor is on. I will often save a file right after starting a new line, and then my indentation disappears :unamused:


this should be fixed now


Hi, and thanks for the update to this. I was wondering if this could be a user-selectable option. Personally I liked it better when I had to re-tab or re-space after save, and acted as a kind of sanity check to make sure all whitespace was stripped.

As it is now, I have to be conscious to switch lines and then save if I tabbed. Not doing so almost let some whitespace get into my commit. I see the benefit of not stripping the line the cursor is on, but would be nice to have the option either way. Thanks.


Hi @zickonezero,
What if, on save, only whitespace from after the cursor was stripped? I think it would be pretty obvious that there is whitespace before the cursor because the cursor wouldn’t be at the start of the line.


Thanks for the reply @mikeyhew, but it’s the whitespace before the cursor that I’m concerned with. If no stripping of whitespace occurs before the cursor, you have to manual delete the whitespace or move the cursor to a new line then save. I may be alone on this, but I like seeing the cursor snap to the beginning of the line on save. It’s kind of a confirmation that whitespace is being stripped, even if it meant tabbing a couple times to return to where I was.


I have implemented this at first since it seemed logical and zedapp behaved the same.

But after using it for a while, i miss cursor snapping too. Also considering that sublime text doesn’t keep whitespace on cursor line, we have changed the default back to striping whitespace on all lines

Keeping current line can be enabled by adding "@stripwsKeepCursorPosition": false to general section of user settings.