如何在VSCode中自动硬换行?我的意思是,如果一行到达了指定的列,自动在最接近该列的单词边界处插入换行符,而不会越过。Vim有一个叫做textwidth的设置,我喜欢在编辑Markdown时使用它。据我所知,VSCode并没有这样做。它只是有办法控制软件。
当前回答
目前在GitHub上的VS代码问题跟踪器中有一个开放的请求,你可以在这里找到它
其他回答
不幸的是,VSCode还没有这个功能。但是,我们仍然可以使它与vim的自动换行功能一样美观。
第一步
我们需要在VSCode中设置软换行功能。
通过Code => Preferences => Settings打开VSCode Settings。 添加这3行编辑器设置。 “编辑器。自动换行”:“wordWrapColumn”, “编辑器。wrappingIndent”:“相同”, “编辑器。wordWrapColumn n”: 不要忘记用你喜欢的列行长度来改变(n)。对我来说,我觉得把它设置为60更舒服。 保存此设置。
这第一步的主要目的是让我们在打字时感觉更舒服,因为我们不需要手动输入Enter并看到一长行文本。
第二步
我们需要为VSCode安装Vim仿真并设置Vim文本宽度。
通过VSCode扩展安装Vim仿真。 通过Code => Preferences => Settings打开VSCode Settings。 添加这一行vim设置。 “vim。textwidth”:n, 不要忘记用你喜欢的列行长度来改变(n)。对我来说,我要在第一步中使它与(n)相同。 保存此设置。
实际使用
当你完成整个文档的写作时,你可以使用这种方法将其格式化为硬换行。
用可视线条模式阻挡所有文本(Shift + v) 类型“gq”
编辑:(下面的答案可能是软包,软包和硬包的区别见这里:https://stackoverflow.com/a/319932/9481613) 在我的版本中,它是首选项->设置,然后向下滚动到“编辑器:自动换行”,其中有一个下拉框,我从其中选择了wordWrapColumn。在选择这个并关闭后,当我点击底部的“查看”时,它会显示“换行Alt+Z”。
其中大多数都不适合我,但我找到了扩展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模拟。
如果有人在运行时遇到问题,可能需要禁用辅助功能支持/屏幕阅读器。转到首选项>>文本编辑器>>可访问性支持,并将其关闭。
VSCode不支持开箱即用。但是您可以安装Rewrap扩展,它允许您通过按Alt + Q来格式化光标当前所在的块。
Rewrap不需要进一步的设置,因为它读取VSCode的设置来获得要中断的列。
Rewrap还支持自动包装(默认关闭):https://github.com/stkb/Rewrap/wiki/Auto-wrap
推荐文章
- 在VS Code中禁用“Comments are not allowed In JSON”错误
- 使用正则表达式搜索和替换Visual Studio代码
- 如何缩进/格式选择的代码在Visual Studio代码?
- 如何禁用预览文件与点击在vs代码?
- Visual Studio代码更改文件资源管理器托盘的字体大小?
- 如何防止Visual Studio Code总是重新打开以前的文件或文件夹?
- VSCode单引号到双引号自动替换
- 如何删除Visual Studio代码中的重复行?
- 如何设置每个文件类型的标签大小?
- 我如何添加环境变量启动。VSCode中的json
- 如何格式化Visual Studio Code项目中的所有文件?
- Pylint在Visual Studio代码中“未解决的导入”错误
- 如何在VS Code中默认打开文本换行
- 在Visual Studio代码中更改突出显示文本的颜色
- Visual studio代码-键盘快捷键-全部展开/折叠