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


当前回答

VSCode不支持开箱即用。但是您可以安装Rewrap扩展,它允许您通过按Alt + Q来格式化光标当前所在的块。

Rewrap不需要进一步的设置,因为它读取VSCode的设置来获得要中断的列。

Rewrap还支持自动包装(默认关闭):https://github.com/stkb/Rewrap/wiki/Auto-wrap

其他回答

硬包装评论

使用Rewrap扩展。

软包装代码

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

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

硬包装注释和软包装代码

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

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

VSCode不支持开箱即用。但是您可以安装Rewrap扩展,它允许您通过按Alt + Q来格式化光标当前所在的块。

Rewrap不需要进一步的设置,因为它读取VSCode的设置来获得要中断的列。

Rewrap还支持自动包装(默认关闭):https://github.com/stkb/Rewrap/wiki/Auto-wrap

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

可以使用C_Cpp中的ColumnLimit成员轻松设置列限制。设置中的clang_format_fallbackStyle。json(你必须安装微软C/ c++扩展)

"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: WebKit, IndentWidth: 4, ColumnLimit: 80 }",

然后你可以使用Shift + Alt + F来格式化文件

在这个格式特性中,您可以更改许多选项

"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: WebKit, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Attach, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 80, AccessModifierOffset: -4 }",

Name of the predefined style used as a fallback in case clang-format is invoked with style file but the .clang-format file is not found. Possible values are Visual Studio, LLVM, Google, Chromium, Mozilla, WebKit, Microsoft, GNU, none, or use {key: value, ...} to set specific parameters. For example, the Visual Studio style is similar to: { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }

之前

void Proc::Memory::getSramOff(const char* mem_name, uint dataSize, uint addrBits, uint& noOfBytes, uint& sram_off)

void Proc::Memory::getSramOff(const char* mem_name, uint dataSize,
    uint addrBits, uint& noOfBytes, uint& sram_off)

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