我正在尝试创建一些设置以在保存时自动检查和格式化 Python 文件。我有 Python 所需的设置,但在编辑 XML 等其他文件时,VSCode 也会自动格式化它们。有没有办法让 VSCode 只格式化 Python 文件?
以下是我的格式化和 linting 设置:
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--max-line-length=240",
"--disable=C0111,unused-import"
],
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"line-length", "250"
],
"python.linting.lintOnSave": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
Run Code Online (Sandbox Code Playgroud)
你可以试试这个,它对我有用,可以防止我的 SQL 文件被格式化。
归功于这里的原始帖子。
"editor.formatOnSave": false,
"[python]": {
"editor.formatOnSave": true,
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1519 次 |
| 最近记录: |