I was just setting up visual studio code so that my python code uses tabs for indentation. Now when I press enter, instead of VSC putting in the correct amount of tabs to stay in the indent, it converts them to spaces. I have seen so many posts that deal with the opposite problem but not with this one. Has this happened to anyone?
example:
counter = 0
while True:
print(Hello World)
counter =1
if counter == 1:
print(counter)
#now when I pressed enter it added only two spaces instead of two tabs
My tab size is set to 4 and I have tried turning on/off the insert spaces setting, and Detect Indentation. Also I have tried clicking on the tab size in the right corner and using the menu there, but nothing has fixed this.
CodePudding user response:
Open your settings.
- Set the Editor: Auto Indent full
2.Set the Editor: Tab Size 4
CodePudding user response:
Option 1
You can choose to indent using spaces or tabs using the command pallete
Ctrl Shift P
or⌘ Shift P
for mac.Choose
Convert Indentation Tabs
. This will fix the problem.
Option 2
You can update the indentation for the VS Code by following these steps:
Select Spaces from bottom right
Choose Indentation type
Choose whether you want to indent using space or tab (tab here).
Choose tab size
The tab size is the number of columns (characters) tab will occupy. You can select that.