在使用代码文件时,通常不需要更长的行来进行换行。然而,对于.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)。


当前回答

对于Dart,请检查设置中的“线长”属性。

其他回答

对于Dart,请检查设置中的“线长”属性。

点击VS Code编辑器中的设置 搜索wordwrap 选择“开启”编辑器自动换行,如下面的截图所示

在1.52及以上版本中,转到文件>首选项>设置>文本编辑器>差异编辑器,并根据您的需要更改换行参数

重新设计换行设置

以下是新的换行选项:

editor.wordWrap: "off" - Lines will never wrap.
editor.wordWrap: "on" - Lines will wrap at viewport width.
editor.wordWrap: "wordWrapColumn" - Lines will wrap at the value of editor.wordWrapColumn.
editor.wordWrap: "bounded" 

行将以视口宽度的最小值和editor.wordWrapColumn的值换行。

特定于语言的编辑器设置,但具体来说:

按Ctrl+Shift+P并输入“Preferences: Configure Language Specific Settings” 选择语言或在文件中添加section(开始键入“[”以查看建议列表),或者如果已经存在,可以根据自己的喜好编辑section。 如果将其设置为有界,则可能需要调整编辑器。要根据屏幕大小进行换行的wordWrapColumn值。有界的行将在viewport和editor.wordWrapColumn的最小值处换行

例子:


    "editor.wordWrapColumn": 200,
    "[markdown]": {
        "editor.wordWrap": "on",
    },
    "[plaintext]": {
        "editor.wordWrap": "bounded",
    },
    "[typescript]": {
        "editor.tabSize": 2,
        "editor.wordWrap": "off",
    },