Python 的 VS 代码在函数调用很长时进入新行

VS Code for Python entering a new line when function call is long

我有一个长期的问题,它让我很生气,所以我会在这里问。当我在 VS Code 中进行长函数调用时,它会自动在参数中的某处换行。

我把这个放在一条线上:

dict_file = os.path.join(path_converted, 
    'dictionary_'+filename+'.picklelongtestlongtestlongtestlongtestlongtest')

并在"(path_converted, 'dictionary_' +"后面添加新行,其余部分缩进新行。

我的显示器很大,所以我不想这么早结束这些台词。我能以某种方式在“设置”中将其关闭吗?我正在使用 FormatOnSave,它很烦人。

谢谢大家的回答:))

安德鲁

VS Code中有以下两个设置:

"editor.wordWrap": 控制换行方式。

"editor.wordWrapColumn":当#editor.wordWrap#为wordWrapColumn或bounded时,控制编辑器的换行列。

所以你的问题有两种解法,写在Settings.json:

  1. 关闭自动换行:

     "editor.wordWrap":"off",
    
  2. 仍然保持 wordWrap 打开,但更改代码的最大长度:

     "editor.wordWrap": "wordWrapColumn",
     "editor.wordWrapColumn":130,