I’m new to PlatformIO and VSC for that matter, I really don’t like and I don’t understand why Arduino have chosen to change the size of tab from the universal 4 spaces into 2 spaces.
I like to change the tab size in PlatformIO, but if I go into settings in VSC I can change the tab size and it is set to 4, so where would I find that setting for PlatformIO?
Is there a preference.txt file such as in the Arduino IDE and if so where is it found?
… you then need to re-format your code (right click → Format Document, or Format Document With... if VSCode is being stupid and listing multiple formatters)
I think the problem is not understood here.
If I open a non-platfomio project in vscode, I get 4 spaces when I hit tab, since Editor: Tab Size is set to 4 already.
However, when I hit tab in a platformio project, I get 2 spaces.
Can anyone help me please ?
No it wasn’t. But your suggestion helped me to figure out what the problem is.
The culprit is the Detect Indentation setting.
Controls whether [Editor: Tab Size] and [Editor: Insert Spaces] will be automatically detected when a file is opened based on the file contents.
I turned off this setting and everything went back to normal.
This is due to the reason that when a new project is made (Arduino based in my case) it starts with the 2 spaced following code:
#include <Arduino.h>
// put function declarations here:
int myFunction(int, int);
void setup() {
// put your setup code here, to run once:
int result = myFunction(2, 3);
}
void loop() {
// put your main code here, to run repeatedly:
}
// put function definitions here:
int myFunction(int x, int y) {
return x + y;
}
And the Detect Indentation setting forces the project to be in 2 space tab from this point on, even if the tab space is set like "editor.tabSize": 4
Does anyone know where the above initial code comes from or how can I change it?