Python 换行符的vscode设置中的格式代码
我们可以使用Ctrl+Shift+i在vs代码中自动格式化代码。 vscode打断长度超过80个字符的行。更改Python 换行符的vscode设置中的格式代码,python,vscode-settings,python-black,Python,Vscode Settings,Python Black,我们可以使用Ctrl+Shift+i在vs代码中自动格式化代码。 vscode打断长度超过80个字符的行。更改线宽不会更改它。 我想在我的python代码中加入120。 解决办法是什么 在之前的问题中,我没有发现类似的问题 这是我的设置.json: { “workbench.panel.defaultLocation”:“右”, “workbench.startupEditor”:“无”, “workbench.sideBar.location”:“right”, “python.pythonP
线宽不会更改它。
我想在我的python代码中加入120。
解决办法是什么
在之前的问题中,我没有发现类似的问题
这是我的设置.json
:
{
“workbench.panel.defaultLocation”:“右”,
“workbench.startupEditor”:“无”,
“workbench.sideBar.location”:“right”,
“python.pythonPath”:“/usr/bin/python3”,
“editor.minimap.enabled”:false,
“workbench.colorTheme”:“Monokai”,
“C_Cpp.updateChannel”:“内部人士”,
“update.showReleaseNotes”:false,
“更新模式”:“手动”,
“workbench.editorAssociations”:[
{
“视图类型”:“jupyter.notebook.ipynb”,
“文件名模式”:“*.ipynb”
}
],
“文件.关联”:{
*.rmd:“降价”
},
“window.zoomLevel”:1,
“更漂亮。打印宽度”:120,
“editor.wordWrap”:“wordWrapColumn”,
“编者.包装材料”:“相同”,
“编辑:wordWrapColumn”:120
}
正如@Subrato所说,这对我来说很有效:
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[python]": {
"editor.defaultFormatter": null
},
"python.formatting.blackArgs": ["--line-length", "120"],
"python.formatting.provider": "black",
在vs代码中的settings.json文件中添加此设置
"editor.wordWrap": "wordWrapColumn",
"editor.wrappingIndent": "same",
"editor.wordWrapColumn": 120
记住editor.wordWrapColumn:120
单独使用是不起作用的,您还需要添加
editor.wordWrap:'wordWrapColumn'
@更新
Prettier不适用于Python<代码>自动EP8
格式是格式化python文件所必需的
使用pip install pep8
将pep8安装到vs代码编辑器中
"python.formatting.provider": "autopep8",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[python]": {
"editor.defaultFormatter": "ms-python.python"
}
//custom config for python
"python.formatting.autopep8Args": ["--max-line-length", "120", "--experimental"],