Visual studio code 如何在VisualStudio代码中打开和关闭换行符?
使用代码文件时,通常不需要较长的行来换行。然而,对于Visual studio code 如何在VisualStudio代码中打开和关闭换行符?,visual-studio-code,Visual Studio Code,使用代码文件时,通常不需要较长的行来换行。然而,对于.md文件,这实际上相当有用。但是,我似乎找不到启用word wrap的选项,因此将换行较长的行 若要复制,请打开大小足够小的Visual Studio代码窗口,并在新文档中输入以下文本: 这是我的测试lorem ipsum。这是我的测试。这是我的测试。这是我的测试。这是我的测试。这是我的测试。这是我的测试。这是我的测试。这是我的测试。 在此之前的换行符。 结果是: 我试图让水平滚动条远离,让第1行环绕在窗口的右侧 我做了一些事情来回答我自
.md
文件,这实际上相当有用。但是,我似乎找不到启用word wrap的选项,因此将换行较长的行
若要复制,请打开大小足够小的Visual Studio代码窗口,并在新文档中输入以下文本:
这是我的测试lorem ipsum。这是我的测试。这是我的测试。这是我的测试。这是我的测试。这是我的测试。这是我的测试。这是我的测试。这是我的测试。
在此之前的换行符。
结果是:
我试图让水平滚动条远离,让第1行环绕在窗口的右侧
我做了一些事情来回答我自己的问题:
- :撰写本报告时,结果为零李>
- 仔细检查Visual Studio代码的菜单:没有找到它李>
- 将命令选项板与“wrap”一起使用:不提供匹配的命令
请注意,我希望能够快速打开和关闭它。首先,@PanagiotisKanavos在评论中提到此解决方案可以更改设置中的换行行为,但我正在寻找一个快速命令或菜单选项来执行此操作(与和2非常相似)。自v1.0以来,您可以切换换行:
- 使用新命令editor.action.toggleWordWrap,或
- 从“视图”菜单(*视图**→ 切换换行符),或
- 使用ALT+Z键盘快捷键(对于Mac:⌥+Z)
- 编辑器.wordWrap
- editor.wordWrapColumn
- 编辑:Wrappingdent
已知问题: 如果您希望修复这些错误,请投他们一票。转到菜单文件→ 偏好→ 用户设置 它将自动打开默认设置和
Settings.json
。只需在settings.json
文件中添加以下内容并保存即可。这将覆盖默认设置
// Place your settings in this file to overwrite the default settings
{ "editor.wrappingColumn": 0 }
我不确定它是何时添加的,但我使用的是v0.10.8和 Alt+Z是打开和关闭自动换行的键盘快捷键。这满足了“能够快速打开和关闭”的要求 关闭Visual Studio代码后,该设置不会保持不变。要持久,您需要通过Radha使用
settings.json
文件的答案来设置它
// Place your settings in this file to overwrite the default settings
{ "editor.wrappingColumn": 0 }
此后,已将换行放在命令选项板中。您可以通过切换Word Wrap或Alt+Z来激活它。查看此屏幕截图(Toogle Word Wrap):
以下是新的换行选项:
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.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" - Lines will wrap at the minimum of viewport width and the value of editor.wordWrapColumn.
行将以视口宽度和
编辑器的最小值换行。wordWrapColumn
换行Column
已被弃用,取而代之的是wordWrap
将此行添加到settings.json以在默认情况下启用wordWrap:
"editor.wordWrap": "on"
或打开用户设置:
Mac:⌘ + ,
Windows:Ctrl+
然后搜索“wordWrap”或滚动“常用”设置以找到它并选择“on”
,可以为换行设置(或任何设置)选择特定语言。可以在命令选项板中的以下位置找到:
首选项:配置特定于语言的设置…
这将带您访问所选语言的“settings.json”,其中可能包括:
"[markdown]": {
"editor.wordWrapColumn": 100,
"editor.wordWrap": "wordWrapColumn"
},
- Windows:Ctrl+Shift+按“P”键。现在在命令行中,键入Toggle Word Wrap并按Enter键
- Mac:命令+移位+按键“P”。现在在命令行中,键入Toggle Word Wrap并按Enter键
- Mac:代码->首选项->设置->在搜索设置->更改编辑器中键入换行符:换行符从关闭转到打开
- Windows:文件->首选项->设置->在搜索设置->更改编辑器中键入换行符:换行符从关闭转到打开
editor.wordWrap:“打开”
。这将始终适用
然而,我们通常会不断改变我们的偏好来检查代码。因此,我使用Alt+Z键包装文件的编写代码,或者您可以转到“菜单视图”→ 切换换行。这适用于你想要的任何时候。再次按住Alt+Z键撤消换行操作(将在一行中显示整行)。这是自2020年5月起的VS代码文档: 以下是新的换行选项:
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.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" - Lines will wrap at the minimum of viewport width and the value of editor.wordWrapColumn.
因此,例如,如果要在窗口边界处缠绕线条,则应:
settings.json
(点击CTRL+SHIFT+p并键入“settings.json”)“editor.wordWrap”:“bounded”
放在json文件中,如下所示:
{
“editor.wordWrap”:“bounded”
}然后它应该可以工作。对于设置中的省道检查“Line length”属性。在1.52版及以上版本中,转到文件>首选项>设置>文本编辑器>差异编辑器并根据需要更改Word Wrap参数-