如何在VSCode中自动硬换行?我的意思是,如果一行到达了指定的列,自动在最接近该列的单词边界处插入换行符,而不会越过。Vim有一个叫做textwidth的设置,我喜欢在编辑Markdown时使用它。据我所知,VSCode并没有这样做。它只是有办法控制软件。


当前回答

硬包装评论

使用Rewrap扩展。

软包装代码

添加以下设置(将列宽替换为您的首选项):"editor. "wordWrapColumn”:100

然后添加任何一个“编辑器”。“wordWrap”:“wordWrapColumn”(在列处换行)或“编辑器”。“bounded”(在列或视口处换行)。

硬包装注释和软包装代码

不幸的是,扩展和VSCode设置不能很好地发挥作用。

欢迎为这个功能请求投票。

其他回答

编辑:(下面的答案可能是软包,软包和硬包的区别见这里:https://stackoverflow.com/a/319932/9481613) 在我的版本中,它是首选项->设置,然后向下滚动到“编辑器:自动换行”,其中有一个下拉框,我从其中选择了wordWrapColumn。在选择这个并关闭后,当我点击底部的“查看”时,它会显示“换行Alt+Z”。

如果有人在运行时遇到问题,可能需要禁用辅助功能支持/屏幕阅读器。转到首选项>>文本编辑器>>可访问性支持,并将其关闭。

硬包装评论

使用Rewrap扩展。

软包装代码

添加以下设置(将列宽替换为您的首选项):"editor. "wordWrapColumn”:100

然后添加任何一个“编辑器”。“wordWrap”:“wordWrapColumn”(在列处换行)或“编辑器”。“bounded”(在列或视口处换行)。

硬包装注释和软包装代码

不幸的是,扩展和VSCode设置不能很好地发挥作用。

欢迎为这个功能请求投票。

其中大多数都不适合我,但我找到了扩展Vsctoix,它可以。

我们从第80列开始换行:

Mechanisms such as a “windfall clause” help distribute riches within particular 
futures. But for a windfall clause to be useful, many conjunctive assumptions 
have to be true. We present a new method to borrow against potential future 
windfalls today, when they have greater marginal use. The method also increases 
the probability and thus the expected value of the windfalls.

然后执行“IX: Join Lines”(无参数):

Mechanisms such as a “windfall clause” help distribute riches within particular futures. But for a windfall clause to be useful, many conjunctive assumptions have to be true. We present a new method to borrow against potential future windfalls today, when they have greater marginal use. The method also increases the probability and thus the expected value of the windfalls.

然后参数为100的“IX: Break Line At”:

Mechanisms such as a “windfall clause” help distribute riches within particular futures. But for a 
windfall clause to be useful, many conjunctive assumptions have to be true. We present a new method 
to borrow against potential future windfalls today, when they have greater marginal use. The method 
also increases the probability and thus the expected value of the windfalls.

如果它尊重换行符并同时执行这两个步骤,那就太棒了,但到目前为止,它是唯一适合我的扩展-除了我还没有尝试过vim模拟。

目前在GitHub上的VS代码问题跟踪器中有一个开放的请求,你可以在这里找到它