386

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?

Stevoisiak
  • 16,510
  • 19
  • 94
  • 173
  • 12
    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 – Juan Mendes Mar 21 '14 at 19:33
  • 1
    This question should be closed as it is off topic. This question belongs on Super User – Mike Caron Mar 21 '14 at 19:54
  • 11
    @MikeCaron That is incorrect See http://meta.stackexchange.com/questions/61726/are-questions-about-ides-on-topic – Juan Mendes Mar 21 '14 at 23:31
  • Possible duplicate of https://stackoverflow.com/questions/8197812/how-does-one-configure-notepad-to-use-spaces-instead-of-tabs. – Ohad Schneider May 23 '17 at 14:19
  • 4
    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. – Omnifarious Apr 27 '18 at 13:40
  • 1
    @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. – AlainD Jun 15 '20 at 12:04

3 Answers3

630

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.

Enter image description here

See documentation: http://docs.notepad-plus-plus.org/index.php/Built-in_Languages#Tab_settings

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
tvanfosson
  • 490,224
  • 93
  • 683
  • 780
  • 28
    Ah Language, now that makes sense. – deed02392 Dec 05 '13 at 16:05
  • The Notepad++ documentation is way outdated. The link above points to Tuxfamily, and they started releasing new builds on Tuxfamily back in [2010](http://notepad-plus-plus.org/news/notepad-5.7-release-(outside-the-usa).html). The online documentation site on Tuxfamily was published in [2011](http://notepad-plus-plus.org/news/release-5.8.7-and-online-documentation-site.html) 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](http://npp-community.tuxfamily.org/) site returns a 404. – Samir Apr 22 '14 at 09:22
  • 5
    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". – Samir Apr 22 '14 at 09:26
  • 43
    The setting is now under **Language**, instead of **Tab Settings**. – David C. Rankin Oct 26 '16 at 07:32
  • Well, now the Notepad++ actually always inserts tabs as spaces, even when the checkbox is unchecked. – Youda008 Mar 12 '20 at 10:28
  • You may want to set the preference per language. For example, say you wish to use spaces in C/C++ code (`*.cpp` and `*.h`), but tabs in normal text files (`*.txt`). Set `[Default]` with `Replace by space` unticked to use tabs generally. Now select `cpp`, untick `Use default value` and tick `Replace by space`. Repeat for all the other source code file types you use. – AlainD Jun 15 '20 at 12:00
61

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

Florian Feldhaus
  • 4,831
  • 2
  • 35
  • 42
arbuzov
  • 783
  • 5
  • 9
2

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

NotePad++ Preferences

NotePad++ Tab Settings

SharpC
  • 5,368
  • 3
  • 37
  • 36