在使用代码文件时,通常不需要更长的行来进行换行。然而,对于.md文件,这实际上相当有用。但是,我似乎找不到启用换行的选项,因此较长的行将被换行。

要复制,打开Visual Studio Code调整到足够小的窗口,并在新文档中输入以下文本:

This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum.
A linebreak before this. 

结果是这样的:

我试图让水平滚动条远离,让第1行环绕在窗口的右侧。

我做了一些事情来回答我自己的问题:

搜索堆栈溢出:在写这篇文章的时候没有结果; 仔细查看Visual Studio Code的菜单:没有找到; 使用“wrap”命令面板:不提供匹配的命令。

也许这是不可能的,我需要提交一个功能请求?还是我遗漏了什么?

注意,我希望能够快速地打开和关闭它。一方面,@PanagiotisKanavos在评论中提到了这个解决方案来改变设置中的包装行为,但我正在寻找一个快速命令或菜单选项来做到这一点(很像notepad++和Sublime Text 2)。


当前回答

从0.3.0版本开始,在命令面板中加入了换行功能。你可以用切换换行或Alt + Z激活它。

其他回答

从1.0版本开始,你可以切换换行:

使用新的命令editor.action。toggleWordWrap或 从“查看”菜单(*查看**→切换自动换行),或 使用键盘快捷键ALT+Z (Mac:“+Z”)。

也可以通过以下设置进行控制:

editor.wordWrap editor.wordWrapColumn editor.wrappingIndent


已知问题:

renderLineHighlight应该突出显示整个逻辑行

如果你想修复这些bug,请投票给他们。

@Riga提供的特定于语言的示例非常棒。对于一般设置,我会推荐以下内容:

"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 90,
"editor.wrappingIndent": "same",

如果你的视口小于列限制(这里是90),这个选项会自动换行文本,并在换行时使用相同的缩进。

步骤1:访问Dart扩展设置

步骤2:找到Dart: Line Length,设置为132,然后保存设置

第三步:按Alt + Shit + F,你会看到行被自动换行。

wrappingColumn已弃用,转而支持wordWrap。

将这一行添加到设置中。默认设置wordWrap:

"editor.wordWrap": "on" 

或打开用户设置:

Mac:⌘+,

Windows: Ctrl +,

然后搜索“wordWrap”或滚动“常用”设置找到它,并选择“on”

进入菜单文件→首选项→用户设置。

它将打开默认设置和设置。自动json。只需在设置中添加以下内容。Json文件并保存。这将覆盖默认设置。

// Place your settings in this file to overwrite the default settings
{ "editor.wrappingColumn": 0 }