Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#1550 Trim trailing spaces on save (CTRL+S and toolbar icon)

tomas cipher

It would be nice if there was a setting that trimmed trailing (end of line) spaces (and tabs) when saving the file. Yes, I know there's a macro to do this, but hitting "Alt+Shift+S" isn't exactly a simple or convenient keyboard command. Ctrl+S is more intuitive. Also, the macro isn't safe to use due to this still existing bug documented here: http://sourceforge.net/tracker/index.php?func=detail&aid=1927783&group_id=95717&atid=612382

I don't see any practical value of having trailing spaces littered throughout the document after saving. Please consider making this a setting that maps directly to all base, internal save commands (ie, "Save", "Save All", "Save a Copy As", plus all save-related toolbar icons).



  • Anonymous

    Actually the bug you referenced has been fixed for a long time now, since about v5.0 I think.

    However, I totally agree that it should be possible to automatically trim trailing space on saving a document.

    Last edit: Anonymous 2014-11-30
  • tomas cipher
    tomas cipher

    Disgruntled Goat, the bug still exists. I'm using the latest version (5.6.6) and if you place the cursor in front of any text and execute "Trim trailing and save" it inserts 10 spaces at that point. This can be reproduced 100% of the time in any file type. This is one of those bugs that is silent but can be hard to locate. I had to perform a regex search through all the files I recently edited with Notepad++ to find all the broken code.

  • Guido Leenders
    Guido Leenders

    I would like this feature too. Manually trimming does not occur very often, and within our environment auto-trim on save would make life better definitely.

  • Totally agree with tomas,
    It would be great if Notepad++ could have the option to choose for the settings "trimmed trailing (end of line) spaces" and "trimmed trailing (end of line) tabs" when saving your file.
    Gracias, Jan

  • patrick

    i would love to have this in N++

  • Xavier S
    Xavier S

    This needs to be in notepad++.
    So great for dev!

  • Marco P
    Marco P

    Yes please, 3 years I use Notepad++ and 3 years that I badly needed this global option ... and not even a plug in.

  • Marco P
    Marco P

    I did temporary and partially got around by disabling the main CTRL+S shortcut, and changing the macro shortcut to CTRL+S.

    However, a global option would be great if triggered on save, save all, close and quit.
    Some editors are shipped with a global option to trim trailing tabs/spaces on open, but this is a different story.


  • fb16

    I agree with the author of this feature request. It would be useful on save, to me too.

  • Kevin

    This would definatly be a handy feature for me.

  • craigc40

    In case votes are being tallied, please add mine. I use the toolbar icon and would like trailing spaces to be trimmed no matter how I save. The macro is helpful, but it's not as convenient as automatic trimming on save.

  • Mike Nystrom
    Mike Nystrom

    Me too. This is especially helpful when importing and exporting to and from Excel. Now I have to start programmers notepad every time that happens, and wen don't want that, do we ;)

    Last edit: Mike Nystrom 2012-12-03
  • steamroller16

    Add my vote too. Automatic trimming on save would really be great.

  • mayl

    Add my vote too. What a great idea! (note that this can already be configured in eclispe/pydev)

  • Jonny

    Got my vote too - any progress with this request seen as though it's been open a while?

    Assuming any change to progress this request will include attaching the macro to 'Save All' as well as 'Save'?

  • I would like this too. Back in the days of DOS, I used an editor that would do this as soon as you leave a line but a global setting to trim trailing spaces on Save would be even better. I often get in trouble for having unknowingly inserting spaces and then failing source code standards validation because I made a small change and forgot to use the clean-up trailing spaces option.

  • I was looking into this and found this thread. I agree this should be a feature. In the meantime, I have switched the Save function and Trim Trailing and save macro shortcuts via the Shorcut mapper in the Settings menu. Settings -> Shortcut mapper...