Trim trailing spaces in GEdit
May 8th, 2009
Uncategorized
One item from the list of good coding standards which always seems to catch me out is that lines of code shouldn’t have trailing white space. Some editors offer functionality to prevent this, GEdit doesn’t by default. A quick search took me to a page of plugin’s including the ‘trailsave’ plugin. When enabled, this plugin trims off all white space from the end of lines; exactly what I want. One small gripe is that it trims off the last line of a file if it is empty, not ideal.
In the spirit of open source, I modified the code slightly and you can now get the remove-trailing-white-space-but-not-the-last-blank-line plugin from here.
Unpack the two files into your ~/.gnome2/gedit/plugins directory (create one if its not there) and start up GEdit. Select ‘Plugins’ from the Edit->Preferences menu and enable the “Save without trailing space’ plugin from that menu.
2 Responses
-
-
John Marino April 18, 2010 at 9:36 pm
Thanks, Jamie. The Ada style check goes bonkers with trailing white spaces, so this was desperately needed. I appreciate it!
John
Hi, my name is Jamie Bennett. I'm a technologist, programmer, researcher, tech evangelist, open source monkey, linux user and self confessed gadget freak.

Works great!