I usually use Notepad++ to write code. I usually remove trailing spaces and convert tab to spaces by manually going into the menus and selecting the relevant menu. The problem that happens is that trailing spaces get introduced inadvertently and so do tab. Later when the file is committed into version control system like Git, it causes confusion during code reviews as it looks like a lot of lines have changed although the only thing that happened there was that trailing spaces were removed or tabs were converted to space and nothing else.

How can I make Notepad++ automatically remove trailing spaces and also convert tabs to space when I click on save button? What do you think is the best solution to this problem?

Is it better if I force git to run a script that does these changes just before files are committed? But then I am not sure how to make Git run a script before commit action is completed.

1 Answer 1


How can I make Notepad++ automatically remove trailing spaces?

These are the precise steps to redirect the standard "Save" shortcut Ctrl+S to do instead "Trim Trailing and Save"

  • Settings->Shortcut Mapper...
  • Main Menu tab, double click on "Save", change S to None
  • Macros tab, double click on "Trim Trailing Space and Save", change to Ctrl+S

The Macros shortcut can also be modified from Macro->Modify Shortcut/Delete Macro...

Source: How do I automatically trim trailing white space with Notepad++?, answer by Antonio. Have a look at the other answers there as well.

How can I make Notepad++ convert tabs to spaces?

Notepad++ can be configured to do this automatically.

Menu > Preferences > Language > None > Default > Tick "Replace by space" and set "Tab Size"

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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