0

我最近使用 pip 安装了yapf并配置了 vscode 的 settings.json 文件,但我不知道如何运行 yapf 格式化当前打开的文件 save。有什么线索吗?

这是我的settings.json文件:

    "[python]": {
        "editor.defaultFormatter": "ms-python.python",
        "editor.tabSize": 4,
        "editor.insertSpaces": true,
        "editor.formatOnSave": true,
        "editor.formatOnSaveMode": "modifications",
        "editor.formatOnType": true,
        "editor.formatOnPaste": true,
    },
    "python.formatting.provider": "yapf",
    "python.formatting.yapfPath": "/usr/local/bin/yapf",
    "python.linting.lintOnSave": true,
    "python.linting.enabled": true,
    "python.defaultInterpreterPath": "python3",

这是我的.style.yapf文件:

[style]
based_on_style = google
spaces_before_comment = 4
indent_width: 2
split_before_logical_operator = true
column_limit = 180

我在用:

  • Mac 操作系统 11.6.1。
  • VS 代码 1.64.0
4

0 回答 0