目录
vs code格式化
函数参数不换行
def generate_canvas_box(
self,
corners,
idxs,
thickness=2,
data_idx=None,
debug = False
):
方法四:使用 VS Code 的自定义格式化设置
打开 VS Code 设置(settings.json):
- 点击右上角的齿轮图标,然后选择“Settings”。
- 在右上角点击
{}
图标,打开settings.json
文件。
添加自定义格式化设置: 在
settings.json
中添加以下内容,以控制自动格式化行为:
{
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--line-length", "120"
],
"editor.formatOnSave": false
}
打开settings.json
找到 VS Code 的用户设置文件夹:
- Windows: 通常在
C:\Users\<Your_Username>\AppData\Roaming\Code\User\settings.json
- macOS: 通常在
~/Library/Application Support/Code/User/settings.json
- Linux: 通常在
~/.config/Code/User/settings.json
- Windows: 通常在
VS code打开命令面板(快捷键ctrl shift P
)搜settings.json
每一行后面都要有逗号
{
"files.autoSave": "onFocusChange",
"python.defaultInterpreterPath": "B:\\ProgramData\\Miniconda3\\python.exe",
"explorer.confirmDelete": false,
"git.openRepositoryInParentFolders": "never",
"remote.SSH.remotePlatform": {
"120.220.95.170": "linux"
},
"editor.minimap.enabled": false,
"python.formatting.provider": "black",
"editor.wordWrapColumn": 200,
"python.formatting.blackArgs": [
"--line-length", "120"
],
"editor.formatOnSave": false
}
禁止 pylance 插件自动添加 import
打开设置,搜索 autoImportCompletions