All files I create in Visual Studio Code version:
Version: 1.95.3 (user setup)
Commit: f1a4fb101478ce6ec82fe9627c43efbf9e98c813
Date: 2024-11-13T14:50:04.152Z
Electron: 32.2.1
ElectronBuildId: 10427718
Chromium: 128.0.6613.186
Node.js: 20.18.0
V8: 12.8.374.38-electron.0
OS: Windows_NT x64 10.0.22631
open with space indentation 1 (my preferred indentation):
However, one of the files opens with space indentation 2 by default:
What is this setting on the file which opens it with default space indentation 2, while all other files open with space indentation 1? What am I doing wrong?
I tried changing the space indentaiton to 1 and then pressing Ctrl+S:
However, when I close it, I expect the setting to be saved, but it reopens with space indentation 2 and still works fine. Why does this file open with default space indentation 2 while others open with default space indentation 1? My file is overriding default settings by default.
I try rewriting it using the Clipboard, but it still happens. I permanently deleted the original file while keeping its contents on the Clipboard, and then paste it in a new file, but it still happens. I had manually rewritten it, but it still is like that. Is it because of the nested conditionals?
Difference
≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈
How to change indentation in Visual Studio Code? has it with 8 spaces on all his files, but it happens on only one file for me.
ᅠᅠᅠᅠᅠᅠᅠᅠᅠ
While I cannot say why it works on some files, but not others, there is a note in the documentation of Visual Studio Code that is of relevance here:
Note: VS Code auto-detection checks for indentations of 2, 4, 6 or 8 spaces. If your file uses a different number of spaces, the indentation may not be correctly detected. For example, if your convention is to indent with 3 spaces, you may want to turn off editor.detectIndentation and explicitly set the tab size to 3.
So I would tell you to try to disable the detectIndentation feature in your user settings. In the Settings menu, search the “detectindentation” keyword.
Might be that for your other files Visual Studio Code did not run the detection at all (file too short maybe) or could determine indentation correctly even though it should not be able to detect indentation of 1 according to the documentation.