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

前端 未结 3 864
独厮守ぢ
独厮守ぢ 2021-02-03 17:51

Using VSCode 1.9.0 with the (donjayamanne) Python 0.5.8 extension, is it possible to provide Python specific editor options?

Or more generally speaking,

相关标签:
3条回答
  • 2021-02-03 18:01

    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.

    0 讨论(0)
  • 2021-02-03 18:01
    1. Editor: Detect Indentation = false (default = true)
    2. Editor: Insert Spaces = true (default)
    3. Editor: Tab Size = 4 (default)
    0 讨论(0)
  • 2021-02-03 18:17

    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
    

    See also:

    https://github.com/editorconfig/editorconfig-vscode

    http://editorconfig.org/

    0 讨论(0)
提交回复
热议问题