"Trim trailing whitespace when saved" speed button feature request

Hi

"Trim trailing whitespace when saved" is a really useful feature, especially for new files. The problem we have is we have to manage multiple release branches in our Git repos and if we enabled this for existing files, it makes that management more difficult as all of a sudden deltas appear everywhere. I know we can ignore EOL whitespace in Git, but again, that requires some management across large teams and there are occasions where we wouldn't want to do that.

What would be a really useful is to have some option on the editor speed button bars to enable it, perhaps a speed button like the Debug Button (or something similar), depressed for "on" otherwise off. That way we can enable it for new files or for certain selected files on a file by file basis. When an editor is loaded, the speed button would default to the "Trim trailing whitespace when saved" default. The button state would also be saved as part of a Workspace save, but perhaps would be tri-state, where null (not explicitly set) would mean use default, otherwise it would explicitly set to what the user had requested.

Thoughts?

Regards
Paul

What I've done in the past with our source control is introduce a single commit that addresses one minor headache and that introduces no real code changes. If it were me I'd strip trailing whitespace from all files in your repo and commit them at once with a comment indicating that this is a trailing whitespace cleanup commit. You then get a single commit in the history and everything following is clean.

Hi

Yes, that is another approach which works on low numbers of version branches, but we have many active version branches (hundreds of client and markets, many of which drag their heels and upgrade at different frequencies) so that would be a large task and would have a knock-on effect on merges / cherry picks / hot fixes, so isn't a practicable solution for us.

Seeing as you have other speed buttons relating to editor action which can be added to toolbars via the "customise" option, could you not add a strip EOL whitespace on / off button? I would've thought it lends itself nicely to that configurable aspect of Toad?

I will log this to make it available as a toolbar customization; it's certainly easy enough to do. I was just thinking that normalizing the code would be the easiest and least fragile solution since your team will need to remember to use the toggle, but only for some files.

Your suggestion is definitely the best approach and something I've suggested in the past to the team, it's just there are inevitable knock-ons at the moment. But the button will definitely come in very useful regardless, and EOL whitespace removal is an elected "on" in the Toad options, if the button defaults to the options, it won't have knock-ons. Thanks very much :+1:

This will be in place for next week's beta. The button is not on the toolbar by default. Customize your toolbar to add it. You can find the command in the "File" category.

1 Like

Great stuff, many thanks

1 Like

Hi Michael

I've noticed an issue with this button. New editor tabs / new loaded files remember the last value set, rather than defaulting to the value set in the Options that I mentioned:

"When an editor is loaded, the speed button would default to the "Trim trailing whitespace when saved" default."

This means I end up causing loads of deltas by accident if I switch it on somewhere.

Regards
Paul

The button is currently just toggling the option, not being set per tab. I'll change it.

1 Like

@Paul - Try again next beta. It should be remembered per-tab now, defaulting to the global setting.

1 Like

Thanks as always, Michael.

1 Like