VS Code自动格式化程序自动在注释和类之间添加行

时间:2020-11-11 14:41:20

标签: python visual-studio-code format comments code-formatting

Windows 10
vscode: v1.51.0
美化: v1.5.0

vs代码中的

Python Auto Formatter在注释和类之间添加了以下几行。
在类之间完成此操作时很好,但是当我想添加
的描述时 使用注释在其上方的一个类,再次在注释和该类之间放置两行

保存之前的代码:

class Hello():
    def ok():
        pass

# ok
class Hi():

    def ok():
        pass

保存后的代码:

class Hello():
    def ok():
        pass

# ok


class Hi():

    def ok():
        pass

Vscode Settings.json

{
    "workbench.colorTheme": "Signed Dark Pro",
    "editor.fontSize": 16,
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    "window.zoomLevel": 2,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "[jsonc]": {
        "editor.defaultFormatter": "HookyQR.beautify"
    },
    "workbench.iconTheme": "material-icon-theme",
    "editor.formatOnPaste": true,
    "editor.formatOnType": true,
    "files.autoSave": "off",
    "python.jediEnabled": false,
    "python.languageServer": "Microsoft",
    "todo-tree.tree.showScanModeButton": false,
    "todo-tree.highlights.defaultHighlight": {
        "icon": "alert",
        "type": "text",
        "foreground": "black",
        "background": "#FF8C00",
        "opacity": 100,
        "iconColour": "#FF8C00"
    },
    "todo-tree.highlights.customHighlight": {
        "TODO": {
            "icon": "check",
            "gutterIcon": true,
            "type": "text-and-comment"
        },
        "FIXME": {
            "foreground": "#AACCFF",
            "background": "#222333",
            "iconColour": "yellow",
            "gutterIcon": true,
            "type": "text-and-comment"
        },
        "COMMENT": {
            "foreground": "red",
            "background": "blue",
            "iconColour": "red",
            "gutterIcon": true,
            "type": "text-and-comment"
        }
    },
    "kite.showWelcomeNotificationOnStartup": false,
    "python.pythonPath": "\anaconda3\\envs\\tf-gpu\\python.exe",
    "todo-tree.general.tags": [
        "XXX",
        "TODO",
        "HACK",
        "FIXME",
        "BUG",
        "todo",
        "COMMENT"
    ],
    "[javascript]": {
        "editor.defaultFormatter": "vscode.typescript-language-features"
    },
    "typescript.updateImportsOnFileMove.enabled": "always",
    "git.autofetch": true,
    "java.home": "C:/Program Files/Java/jdk-13.0.2",
    "C_Cpp.updateChannel": "Insiders",
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "java.refactor.renameFromFileExplorer": "autoApply",
    "java.project.importOnFirstTimeStartup": "automatic",
    "editor.formatOnSave": true,
    "diffEditor.codeLens": true
}

1 个答案:

答案 0 :(得分:0)

我注意到您在设置中使用了<ImageBackground source={{ uri: base64Val }}> 。对于您描述的问题,建议您添加以下设置来使用它:

"editor.formatOnSave": true,

保存(格式化)文件之前和之后:

enter image description here