458

Notepad++ keeps inserting tabs which later messes up my code. This doesn't just happen when I hit the tab key, but other times as well. I want it to use 4 spaces instead of tabs.

How can I make Notepad++ insert spaces instead of tabs?

7
  • 19
    The linked question is not a dupe. This is not asking about how to run a macro that converts, it's asking about never entering tabs in the first place when indenting your code for you. And the answer here is correct Commented Mar 21, 2014 at 19:33
  • 1
    This question should be closed as it is off topic. This question belongs on Super User Commented Mar 21, 2014 at 19:54
  • 15
    @MikeCaron That is incorrect See meta.stackexchange.com/questions/61726/… Commented Mar 21, 2014 at 23:31
  • 6
    And for Python, this makes the difference between correct code and not. IMHO, Notepad++ should be shipping with this setting turned on by default for Python code. Commented Apr 27, 2018 at 13:40
  • 2
    @Omnifarious: v7.8.6 (April 2020) has the python option set to use spaces. Not sure how long this has been there. As a side note...Notepad++ is awesome. Commented Jun 15, 2020 at 12:04

5 Answers 5

735

Go to the Preferences menu command under menu Settings, and select Language Menu/Tab Settings, depending on your version. Earlier versions use Tab Settings. Later versions use Language. Click the Replace with space check box. Set the size to 4.

Screenshot

See documentation: https://npp-user-manual.org/docs/preferences/#language

Sign up to request clarification or add additional context in comments.

7 Comments

Ah Language, now that makes sense.
The Notepad++ documentation is way outdated. The link above points to Tuxfamily, and they started releasing new builds on Tuxfamily back in 2010. The online documentation site on Tuxfamily was published in 2011 and it's for version 5.8.7. Notepad++ is at version 6.5.5 right now, and the "Help Contents" menu option brings up a local copy of the doc site. Visiting Tuxfamily site returns a 404.
It's unfortunate that the doc site is so outdated. But the screenshot above points correctly to the appropriate option (version 6.5.5). So this setting is located under "tab settings" now, it's no longer shared with "language menu".
The setting is now under Language, instead of Tab Settings.
Well, now the Notepad++ actually always inserts tabs as spaces, even when the checkbox is unchecked.
|
71

In my Notepad++ 7.2.2, the Preferences section it's a bit different.

The option is located at: Settings / Preferences / Language / Replace by space as in the Screenshot.

Screenshot of the windows with preferences

1 Comment

This is the new settings for latest Notepad++
6

I have NotePad++ v6.8.3, and it was in Settings → Preferences → Tab Settings → [Default] → Replace by space:

NotePad++ Preferences

NotePad++ Tab Settings

1 Comment

You can keep the default as a tab but change specific languages to spaces (or vice versa). Just select and set each language that you use on this screen.
5

In Notepad++ v8.7 it is now in the Indentation tab in preferences (Settings → Preferences → Indentation): Indentation settings

Comments

1

Notepad++ 8.6.9's preferences look somewhat different from existing answers' screenshots:

Screenshot of Notepad++ 8.6.9 preferences dialog

In the hope this can help someone else, I have to answer the question opposite from the OP's: my problem was that Notepad++ wouldn't honour my choice to use tabs for indenting Python files, and it would insert 4 spaces even in an already tab-indented file.

The solution was to go to Settings > Preferences..., then Language > [Your desired language], then the trick is that under Indent Settings, instead of "[Default]", you should choose again the desired language, then override the settings to whatever you like.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.