I think what you want to achieve should be at the database level, not in scripts.

If you want to do it by script (and add a trigger to each and every object, which I really wouldn't recommend), you can just use Set Field without specifying the field, and specify the calculation like : Trim ( TextFormatRemove ( Get ( ActiveFieldContents )) (for example, but you could also avoid leading/trailing carriage return)

If you want to do it at the database level, specify an auto enter calculation like

Trim ( TextFormatRemove ( self ))

and un check the Do not reevaluate checkbox.

(You can also create a custom function like text.clean ( text ) and use text.clean ( self ) in the auto enter, this will make it easier if you once want to change this calculation)