我们可以在 vs 代码中使用Ctrl++Shift来i自动格式化代码。vscode 断行超过 80 个字符。改变linewidth
不会改变它。我想把 120 放在我的 python 代码中。解决办法是什么?
我没有发现类似的问题挖掘以前的问题。
这是我的setting.json
:
{
"workbench.panel.defaultLocation": "right",
"workbench.startupEditor": "none",
"workbench.sideBar.location": "right",
"python.pythonPath": "/usr/bin/python3",
"editor.minimap.enabled": false,
"workbench.colorTheme": "Monokai",
"C_Cpp.updateChannel": "Insiders",
"update.showReleaseNotes": false,
"update.mode": "manual",
"workbench.editorAssociations": [
{
"viewType": "jupyter.notebook.ipynb",
"filenamePattern": "*.ipynb"
}
],
"files.associations": {
"*.rmd": "markdown"
},
"window.zoomLevel": 1,
"prettier.printWidth": 120,
"editor.wordWrap": "wordWrapColumn",
"editor.wrappingIndent": "same",
"editor.wordWrapColumn": 120
}
正如@Subrato 建议的那样,这对我有用:
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[python]": {
"editor.defaultFormatter": null
},
"python.formatting.blackArgs": ["--line-length", "120"],
"python.formatting.provider": "black",