如何避免在 VS Code 中的包装行上出现多光标?

Fab*_*ian 5 visual-studio-code vscode-settings

题:

我在 VSCode 中打开了 wordWrap,因此如果我调整窗口大小,则行会被换行。

如果我想注释掉一些代码或文本,我通常只是将光标移动到代码块的第一行的开头,使用 ctrl+shift+down 添加光标,然后键入 // 或 # 等。

wordWrap 的问题在于,我不仅在每个实际行的开头获取光标,而且还在编辑器中显示的每一行的开头获取光标。

假设文档: 1 This is the first line. 2 Second line.

这可能被包装如下: 1 This is the first line. 2 Second line.

所以如果我使用上面的方法并添加 % 我会得到: 1 %This is the first %line. 2 %Second line.

但我想要的是以下内容: 1 %This is the first line. 2 %Second line.

否则,我在行中间有一个 % ,只是因为我调整了编辑器窗口的大小...

目前,我实际上关闭了 wordWrap 来实现这一点,但我希望有更好的方法吗?

请注意:

对于添加注释,使用ctrl+/shift+ alt+实际上更简单a。但也许这个问题对于其他情况仍然很有趣。

Kyl*_*Mit 2

更新v1.62 +(2021 年 10 月)

由于此 PR 关于更改 InsertCursorAbove/Below 的默认行为,现在可以在 VSCode 中本地使用此功能。但是,默认情况下它并未启用。

您需要更新您的键绑定以传递args如下内容:

{
  "key": "shift+alt+down",
  "command": "editor.action.insertCursorBelow",
  "when": "textInputFocus",
  "args": { "logicalLine": true },
},
{
  "key": "shift+alt+up",
  "command": "editor.action.insertCursorAbove",
  "when": "textInputFocus",
  "args": { "logicalLine": true },
},
Run Code Online (Sandbox Code Playgroud)