作者:倒叙的时光_SX_126 | 来源:互联网 | 2023-02-12 15:23
使用VSCode 1.9.0和(donjayamanne)Python 0.5.8扩展,是否可以提供Python特定的编辑器选项?
或者更一般地说,是否可以提供特定语言的制表符间距和替换规则?例如,Python应该是tab = 4个空格(替换为空格),而Ruby应该是tab = 2个空格(替换).其他语言往往有自己的意见.但是,我只看到将军
"editor.tabSize": 4,
"editor.insertSpaces": true,
选项.
我想也许有一个"python.editor": { }
块或者一个"python.editor.tabSize"
选项,但是我找不到这样的参考,也没有成功猜到一个工作名称.
1> zeljko_a..:
我今天遇到了同样的问题.
这是我修复它的方式.在VSCode中的setting.json中添加以下行:
"[python]": {
"editor.insertSpaces": true,
"editor.tabSize": 4
}
它就像一个魅力.
2> Shaun Luttin..:
Python应该是tab = 4个空格(替换为空格),Ruby应该是tab = 2个空格...
安装编辑器配置插件.
ext install EditorConfig
.editorconfig
使用Python和Ruby特定设置将文件添加到项目根目录:
[*.py]
indent_style = space
indent_size = 4
[*.rb]
indent_style = space
indent_size = 2
这些是其他支持的属性:
tab_width
end_of_line
insert_final_newline
trim_trailing_whitespace
也可以看看:
https://github.com/editorconfig/editorconfig-vscode
http://editorconfig.org/