Trim trailing white spaces in source code

Is there an option or function to trim trailing white spaces from source code, while or after typing, or when exporting DDL?

There is a regular expression you could use for that, but I don't know of any other way.

Text to find: ([^ \t\r\n])[ \t]+$
Replace with: \1

It would be a useful option. I have seen developers take exported DDL scripts and strip the trailing whitespace using Notepad++.

1 Like

Thanks.
Being "lazy", I was hoping Toad editor would have a "Right-click" -> "Remove Trailing Blanks" :slight_smile:

This all seems rather clunky, though. Couldn't there be an option in TOAD to remove trailing whitespace on load or compile or save? I suppose formatting removes trailing spaces, but what about removing spaces without formatting?

But, there is this: Code that is under CM that has had previously existing whitespace stripped by a dev who just actually changed a single line could 'fool' the CM tool into thinking EVERYTHING changed instead. It may be that some CM software is smart enough not to be fooled but probably not all are.

Cheers,
Russ

If I recall correctly, I'm pretty sure Toad had this as an editor option back when Toadman was the author, but it seemed to have been dropped at some point over the years. Pretty much every other IDE I use has this as an editor option, and when enabled, applies it when you save the file.

I must admit, I hate trailing whitespace, especially in Git repositories, it's just character noise / bloat. I have a Replace Macro using regex setup for doing it:

Find : [ \t]+$
Replace With :

but as there is no option to assign a keyboard shortcut to a macro (something I asked for here,) it makes it quite cumbersome to use.

@Paul the macro shortcut has been logged, but no work has been performed there yet.

Trim trailing whitespace option... that definitely needs to be added. I'm with you on an option to trim. I'll log that to be done sooner than later. I also enable that in any tool I use that provides it.

1 Like