Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I don't want to delete the empty lines completely, but I want to remove the tabs and whitespaces in them. Eclipse usually does it (through a preference setting I guess) when we save the file.

For example, the file before saving ($ = end of line):

def shuffle(list):$
    import random $

... and when I save this in the editor, Eclipse does the following:

def shuffle(list):$
    import random$

Is this possible in Notepad++?

share|improve this question

3 Answers 3

up vote 14 down vote accepted

You should be able to do a regex find/replace in notepad++ using a pattern like \s+$.

There are also a few options under Edit -> Blank operations that may fit your needs.

EDIT: Under the "Macro" menu there's an option for "Trim trailing and save". If you need to do a regex it may be possible to create a macro however I've never tried them.

share|improve this answer
yes in my version of Notepad++, there's an Edit -> Trim Trailing Space, but can I trigger that automatically for every save? –  Srikanth Jan 9 '14 at 18:36
There's an option for "Trim trailing and save" under the Macro menu –  johanno Jan 9 '14 at 18:39
Excellent, thanks, that will do. –  Srikanth Jan 9 '14 at 20:49
I have bound the Ctrl+S key to the Macro -> Trim Trailing and save option, using the Settings -> Shortcut Mapper... option. This is much better than having to remember to run the macro all the time. :) –  Darthfett Jan 9 '14 at 22:54
Darthfett, thanks very much. –  Srikanth Jan 10 '14 at 21:09

Control+f -> Switch to replace ->

Find what: \t\r

Replace with: \r

Make sure Extended search mode is on, then replace all.

EDIT: After reading the question again, I realize you want to save as well. In this case, johanno has the correct solution. Macro -> Trim Trailing and Save works as specified.

share|improve this answer

Alt+Shift+S does what you want. In fact it also saves the file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.