Python indentation support
-
I am not sure whether this is the correct place to post this. I am current in Notepad++ (7.7.1) and despite assertion to the contrary, indentation in .py files (Python), still defaults to tabs rather than to 4 spaces.
What do I miss?
ZA -
I’ve just download a fresh zip, unpacked it a nd tested it.
Python indentation was done using 4 spaces.Could it be that your expectation was that tabs in existing code gets automatically
converted into spaces?
If so, no, this doesn’t happen and if you copy/paste source into a python document,
tabs don’t get converted either. -
I don’t know if this is the case for you, but I’d suspect that if you update from an existing version that has tabs as the default, upgrading to a very recent version where spaces are the default…doesn’t change the setting for you (it keeps what you had). Only brand new installs would get the spaces behavior. Or I’m wrong.
-
Regarding this:
if you copy/paste source into a python document,
tabs don’t get converted either.…if that’s a key point of interest, then this thread may contain good info:
-
I did not expect existing files with tabs to convert, but I expected something like (in an absolutely new file:)
class a1
…x=1 # Here I typed four spaces, the dots represent spaces <enter>
Here notepad++ did a tab, but I expected four spacesI suspect that Alan is correct in saying “but I’d suspect that if you update from an existing version that has tabs as the default, upgrading to a very recent version where spaces are the default…doesn’t change the setting for you (it keeps what you had). Only brand new installs would get the spaces behavior.”
Is there a way to change the default short of totally uninstalling notepad++ and reinstalling?
Thanks
ZA -
Hi, @zeev-atlas, @ekopalypse, @alan-kilborn and All,
May be I’ll be totally wrong, but why not use the indentation preferences, in Notepad++
Settings
?
Among my multiple N++ local versions, the last one, where I installed the Python plugin, is the
v7.6.3
version.After a quick test, in a new Python file, I confirm that hitting the TAB key wrote a tabulation char (
\x09
), as mentioned by @zeev-atlas !Now :
-
Go to
Settings > Preferences... > Language > Tab Settings
-
Select the
Python
item, near the end of the drop-down list -
Untick the
use default value
option -
Verify that the tab size value is
4
-
Tick the
Replace by space
option -
Click to the
Close
button to valid the changes close the Preferences dialog
=> From now on, any hit on the
TAB
key will write, automatically,4
spaces as leading indentation ;-))
Again, I may have completely misunderstood the problem !
Best Regards,
guy038
-
-
no you are not wrong, as of npp 7.7 the standard, for python, is to use spaces instead of tabs.
-
The original complaint was that
Notepad++ (7.7.1) ... indentation in .py files (Python), still defaults to tabs rather than to 4 spaces
And this is simply not true. Notepad++ 7.7.1 defaults .py file indentation to spaces, not tabs.
Sure, it is easily changeable, but that’s not what we’re talking about here. We’re talking about what it defaults to.
-
Thanks for all the tips mentioned in this article! it’s always good to read things you have heard before and are implementing, but from a different perspective, always pick up some extra bits of information.
-
Your posting in this thread is OK, but your profile points in the other direction. Tread lightly.