Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Extension to fix inconsistent tab issue of Python [closed]

Tags:

First of all, I wonder who was the brainless genius that decided to have indentation based language, and why couldn't he simply used semi-colons. It is so frustrating that the tabs in python files are always go out of sync, specially when you change either an editor and/or OS.

Just wondering if there is an extension in VSCode that could fix this tab inconsistency?

like image 941
Hafiz Temuri Avatar asked Apr 16 '18 20:04

Hafiz Temuri


People also ask

How do you fix an inconsistent indent in Python?

The Python "TabError: inconsistent use of tabs and spaces in indentation" occurs when we mix tabs and spaces in the same code block. To solve the error, remove the spacing and only use tabs or spaces, but don't mix the two in the same code block.

How do you fix tab errors in Python?

The Python “TabError: inconsistent use of tabs and spaces in indentation” error is raised when you try to indent code using both spaces and tabs. You fix this error by sticking to either spaces or tabs in a program and replacing any tabs or spaces that do not use your preferred method of indentation.

How do I fix indentation in Visual Studio python?

Go to "Command Palette" Ctrl + Shift + P (View>Command Palette) Type in & select "Convert Indentation to Tabs" and press Enter.

How do you remove inconsistent tabs and spaces in indentation?

Try deleting the indents and then systematically either pressing tab or pressing space 4 times. This usually happens to me when I have an indent using the tab key and then use the space key in the next line.


1 Answers

You can fix the tab inconsistency by converting all indentation to tab or spaces. If you open the "Show All Commands" tab, ( by pressing Ctrl+Shift+P or F1 ) and search for "convert indentation", two options will by available:

  • convert indentation to tabs
  • convert indentation to spaces

Just choose tabs if you use tabs or spaces if use spaces as your indentation method.

like image 135
Renan Lopes Avatar answered Sep 24 '22 14:09

Renan Lopes