close

How to set Python language specific tab spacing in Visual Studio Code?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to set Python language specific tab spacing in Visual Studio Code in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to set Python language specific tab spacing in Visual Studio Code?

  1. How to set Python language specific tab spacing in Visual Studio Code?

    I had the same problem today.
    This is how I fixed it. Add this lines in setting.json in VSCode:

  2. Python language specific tab spacing in Visual Studio Code

    I had the same problem today.
    This is how I fixed it. Add this lines in setting.json in VSCode:

Method 1

I had the same problem today.
This is how I fixed it. Add this lines in setting.json in VSCode:

"[python]": {
  "editor.insertSpaces": true,
  "editor.tabSize": 4  
}

It works like a charm.

Method 2

Python should be tab=4 spaces (replaced as spaces), and Ruby should be tab=2 spaces…

Install the editor config plugin.

ext install EditorConfig

Add an .editorconfig file to your project root with Python and Ruby specific settings:

[*.py]
indent_style = space
indent_size = 4

[*.rb]
indent_style = space
indent_size = 2

These are other supported properties:

tab_width
end_of_line
insert_final_newline
trim_trailing_whitespace

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read