Notepad++ indentation messes up

I'm coding in Python and I really like Notepad++. However, off late when I use tab to indent, it seems fine in Notepad++, but when I run the program I get an indentation error, and when I check my code in Emacs or something, I find that Notepad++ actually adds more tab spaces than it shows on screen. What is happening?


Solution 1:

There is no universal tab size, so I always make sure to replace tabs by spaces (so you know what you see is what you get everywhere else as well)

Go to Settings -> "Preferences..." -> Language Menu/Tab Settings and check 'Replace by space'

Solution 2:

I would suggest going to View > Show Symbol > Show Whitespace and Tab to get an better idea of how your indentations look.

Solution 3:

PEP 8 tells us to use spaces instead of tabs in Python for cross-editor compatibility and consistency:

http://www.python.org/dev/peps/pep-0008/

Have a look at this answer for how to change tabs to spaces in Notepad++

Convert tabs to spaces in Notepad++

Perhaps that will fix your problem

Solution 4:

Tiny update - to get spaces as tabs, you now go to Settings>>Preferences>>Tab Settings and check the "Replace by space" box