如何在 Visual Studio Code 中打开和关闭自动换行? [英] How can I switch word wrap on and off in Visual Studio Code?

查看:77
本文介绍了如何在 Visual Studio Code 中打开和关闭自动换行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用代码文件时,您通常不需要更长的行来环绕.但是,对于 .md 文件,这实际上非常有用.但是,我似乎找不到启用自动换行的选项,因此会换行较长的行.

When using code files, you typically don't need longer lines to wrap around. However, with .md files this is in fact rather useful. However, I can't seem to find the option to enable word wrap so longer lines will be wrapped.

要重现,请打开调整为足够小的窗口大小的 Visual Studio Code,然后在新文档中输入以下文本:

To reproduce, open Visual Studio Code resized to a small-enough window, and enter the following text in a new document:

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 行环绕在窗口的右侧.

I'm trying to get the horizontal scrollbar to stay away, having line 1 wrap around at the right side of the window.

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

I've done a few things to answer my own question:

  • 搜索堆栈溢出:撰写本文时结果为零;
  • 仔细浏览Visual Studio Code的菜单:没找到;
  • 使用带有wrap"的命令面板:不提供匹配的命令.
  • Search Stack Overflow: zero results at the time of writing this;
  • Meticulously going through the menu of Visual Studio Code: didn't find it;
  • Using the Command Palette with "wrap": gives no matching commands.

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

Perhaps it's not possible, and I'd need to file a feature request? Or am I missing something?

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

Note that I'd like to be able to turn it on and off quickly. For one, @PanagiotisKanavos mentioned in comments this solution to change wrapping behavior in the settings, but I'm looking for a quick command or menu option to do this (much like Notepad++ and Sublime Text 2 have).

推荐答案

从 v1.0 开始,您可以切换自动换行:

Since v1.0 you can toggle word wrap:

  • 使用新命令editor.action.toggleWordWrap,或
  • 查看菜单(*查看** → 切换自动换行),或
  • 使用 ALT+Z 键盘快捷键(对于 Mac:+Z).
  • with the new command editor.action.toggleWordWrap, or
  • from the View menu (*View** → Toggle Word Wrap), or
  • using the ALT+Z keyboard shortcut (for Mac: +Z).

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

It can also be controlled with the following settings:

  • editor.wordWrap
  • editor.wordWrapColumn
  • editor.wrappingIndent

已知问题:

  1. renderLineHighlight 应突出显示整个逻辑线

如果您希望修复这些错误,请为它们投票.

If you'd like these bugs fixed, please vote for them.

这篇关于如何在 Visual Studio Code 中打开和关闭自动换行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆