Jamie Bennett Speaks

Thoughts from Jamie Bennett

Trim trailing spaces in GEdit

Written by Jamie Bennett on May 8th, 2009 at 9:38 am in 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.

5 Responses to 'Trim trailing spaces in GEdit'

Subscribe to comments with RSS or TrackBack to 'Trim trailing spaces in GEdit'.

  1. Works great!

    bobby

    7 Nov 09 at 4:18 pm

  2. Thanks, Jamie. The Ada style check goes bonkers with trailing white spaces, so this was desperately needed. I appreciate it!

    John

    John Marino

    18 Apr 10 at 9:36 pm

  3. Thanks!

    Vitaly

    12 Oct 10 at 2:51 pm

  4. great! exactly what i need..thanks!

    cho

    15 Oct 10 at 6:24 am

  5. Thank you! This should be in gedit-plugins package!

    Korshun

    27 Jan 11 at 3:40 pm

Leave a Reply