When coding in whatever language, i always avoid tabs - for me they are confusing, and easily create "hadouken" effect (like https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/hadouken-indentation.jpg )

The problem is that, by default, or by misfeature, Godot's (3.2) code editor automatically uses tab for indenting, and easily get into an avalanche of error messages saying that spaces and tabs can't be mixed when indenting (when i never typed whatever tab, at all)

So, how can this situation be fixed, when using Godot's code editor? (for now i'm using an external code editor, Pluma, just like we usually do on other engines like Unity - but i imagine it's not the greatest "solution", when Godot indeed comes with a code editor...)

Well, the indentation is part of the syntax, so you can't really avoid it. I personally like tabs, because they are easier for me to work with, but I understand it is a personal preference. Also, if you are using more than 2 or 3 levels of indentation, there is probably something wrong with your design.

That said, you can change the Godot editor's use of tabs or spaces in the settings. Click "Editor" on the top then "Editor Settings" then under "Text Editor" click "Indent" on the left. You should see now you can select spaces and set how many you want, if the editor should auto-indent, etc.

6 days later

Unlike spaces, tabs don't have a "defined" width; they can be of any width in your editor. Therefore, the "Hadouken effect" you mention isn't linked to the use of tabs or spaces, but rather the displayed indentation width (which defaults to 4 in all modern editors I know of).

Completely agree that if you’re indenting more than 2 or 3 times there are probably better ways to write your code.

I set mine to use spaces because copying and pasting from tutorials always gives you spaces and I nearly went insane when the editor complained about mixed indents. (I’m a GDScript newbie from the JS world where indents are optional)

In the script editor there is an option to convert indents from spaces to tabs and tabs to spaces. It can make working with code from different sources a little easier. The option is in the edit drop down menu in the script editor, if I remember correctly.

3 years later