1

Notepad++ tabs are made of 4 space. How can I use the actual tab character, so my python code wont raise an indentation error?

astro NOT
  • 11
  • 2
  • To reiterate, using tabs over spaces is not required in Python. However, you must avoid using mixed tabs and spaces for indentation in the same script (likely what is causing your indentation error(s)). – Anaksunaman Apr 30 '21 at 10:58
  • Notepad++ tabs IS made of tabs. Type 'Tab' in a new document and it becomes a Tab, not 4 spaces (if it really does.. maybe a clean re-install will help.) afaik, It become 4 spaces due to the identified (code) language setting. if the language of the file is not identified yet, the typing a tab will return a tab. – p._phidot_ Aug 08 '21 at 16:43

1 Answers1

3

You can change tab length via Settings >> Preferences >> Language

enter image description here

Toto
  • 17,001
  • 56
  • 30
  • 41
  • Fam, i dont wanna change the lenght, but to set the tab to be a "tab character" not spaces, or if changing the lenght will stop giving indentation erros, please do let me know what lenght should I use :) – astro NOT Apr 30 '21 at 08:36
  • 3
    @astroNOT: UNcheck `Replace by space` just under `Tab size` – Toto Apr 30 '21 at 08:37
  • @astroNOT: I suggest you to not use tabs for indentation, they have different length on each tool/editor. Use spaces all the time, a space is always a space in evry tool. – Toto Apr 30 '21 at 08:38
  • You cannot indent in python using spaces :D, tools like pycharm convert those for you into tabs innit – astro NOT Apr 30 '21 at 08:46
  • 2
    @astro NOT *"You cannot indent in python using spaces"* -- You absolutely can indent using spaces in Python. What you cannot do is have *mixed* tabs and spaces for indentations in the same document (script). That is why code editors such as Pycharm or Notepad++ use either tabs *or* spaces. If Pycharm is doing conversion from spaces to tabs, that's the reason. Not because spaces can't be used in Python. – Anaksunaman Apr 30 '21 at 10:42
  • 2
    @astroNOT [*"Spaces are the preferred indentation method. ... Python 3 disallows mixing the use of tabs and spaces for indentation"*](https://www.python.org/dev/peps/pep-0008/#id18) – phuclv Apr 30 '21 at 10:55