How to set Python language span in Visual Studio Code?

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

Or, more generally, is it possible to set language intervals and replacement rules? For example, Python should have tab = 4 spaces (replaced as spaces), and Ruby should have tab = 2 spaces (replaced). Other languages ​​have their own opinions. However, I see only the general

"editor.tabSize": 4, "editor.insertSpaces": true, 

options.

I thought that maybe there is a "python.editor": { } block "python.editor": { } or maybe "python.editor.tabSize" , but I can’t find a link to it, and I didn’t guess the working name.

+6
source share
3 answers

I had the same problem today.
This is how I fixed it. Add these lines to settings.json in VSCode:

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

It works like a charm.

+6
source

In VSCode 1.9.0, language-specific parameters have been added. The syntax for this in settings.json as follows:

 "[python]": { // python-specific settings, for instance: "editor.fontLigatures": true } 

Unfortunately, the settings "editor.tabSize" and "editor.insertSpaces" are in the list of settings that are currently not supported by this syntax (mentioned in the documentation here ).

However, it seems that this will be possible in the upcoming February issue, see # 19511 . If you do not want to wait until then, you can use Insider Build .

+1
source

Python should have tab = 4 spaces (replaced as spaces), and Ruby should have tab = 2 spaces ...

Install the editor settings plugin.

 ext install EditorConfig 

Add the .editorconfig file to the project root using the special Python and Ruby 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/

+1
source

Source: https://habr.com/ru/post/1014808/


All Articles