有可能像Sublime Text一样启用多行编辑吗?

例如,按Ctrl键可以放置额外的游标插入符号,并且可以同时在文档中的多个位置进行写入/删除操作。


当前回答

1.43版(2020年2月)

你现在可以切换列选择模式,改变鼠标手势和方向键,通过:

菜单栏>选择>选择列的方式 Ctrl+Shift+P (Show All Commands) >切换列选择模式 绑定命令"editor.action.toggleColumnSelection"的键

注:激活后状态栏有“列选择”面板,按下可再次禁用。

其他回答

在Windows操作系统中,按住“Ctrl+Alt”同时按“上↑”或“下↓”可以添加游标。

苹果电脑: ⌥ 选择+⌘ 厘米+↑/↓

Linux: Shift + Alt +↑/↓

请注意,第三方软件可能会干扰这些快捷方式,使它们无法正常工作(特别是Windows上的英特尔高清图形软件;详见评论)。 如果你遇到这个问题,你可以禁用Intel/其他软件热键,或者修改VS Code快捷键(如下所述)。

按Esc重置为单个光标。

或者,正如Isidor Nikolic指出的那样,您可以按住Alt键并左键单击任意放置游标。

您可以通过以下方式查看和编辑键盘快捷键:

文件→首选项→键盘快捷键

文档:

https://code.visualstudio.com/docs/customization/keybindings

官方VS Code键盘快捷小抄:

https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf

在Mac上是:

选项+命令,同时按向上↑或向下↓键。

我认为这取决于你的Visual Studio Code版本。

我的是Linux版本Visual Studio Code 1.7.2。

{ "key": "ctrl+shift+up",         "command": "editor.action.insertCursorAbove",
                                     "when": "editorTextFocus" },
{ "key": "shift+alt+up",          "command": "editor.action.insertCursorAbove",
                                     "when": "editorTextFocus" },
{ "key": "ctrl+shift+down",       "command": "editor.action.insertCursorBelow",
                                     "when": "editorTextFocus" },
{ "key": "shift+alt+down",        "command": "editor.action.insertCursorBelow",
                                     "when": "editorTextFocus" }

关键是所有机器的快捷方式都不一样,所以您应该检查您的配置。进入菜单:

菜单文件→首选项→键盘快捷键

搜索editor.action.insertCursorAbove和editor.action.insertCursorBelow并查看当前配置。如果它们与操作系统的快捷键冲突,您可以更改它们。

对我来说,工作解决方案是首先选择需要编辑的文本,然后使用CTRL + F2选择页面中所有匹配的数据。 你也可以按照@lesterCovax的建议使用CTRL+Shift+L

请注意:上面的解决方案使用VSCode编辑器固有的能力在整个页面中选择类似的文本,因此,要小心。

对我来说,上面的Ctrl + ALT +箭头键的解决方案没有工作,因为它导致屏幕改变其显示方向,反对在VSCode中选择行。

你可以用Alt +点击其他游标。如前所述,Ctrl + Alt +↑或↓。