![](/img/trans.png)
[英]Auto save adds two empty lines between comment and function header in Python in VS code
[英]VS Code Auto-Formatter Automatically Adds Lines Between Comments and Class
視窗 10
vscode: v1.51.0
美化: v1.5.0
vs 代碼中的Python Auto Formatter
程序在注釋和類之間添加了這些行。
當這在類之間完成時很好,但是當我想添加一個描述時
使用注釋在其上方的類,它再次在注釋和類之間放置 2 行
保存前的代碼:
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
}
您可以通過在.vscode/settings.json
使用以下配置來禁用它
{
"python.formatting.provider": "autopep8",
"python.formatting.autopep8Args": [
"--ignore=E302"
]
}
以下是解釋的所有autopep8
功能: https : //github.com/hhatto/autopep8#features
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.