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

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


当前回答

在窗口中,您可以通过按下下面/前面的行创建额外的光标:

Ctrl + Alt + Shift +下/上

错过Shift会让你的屏幕翻转。

创建额外的游标将允许您一次编辑多行。

其他回答

我认为这取决于你的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并查看当前配置。如果它们与操作系统的快捷键冲突,您可以更改它们。

在Windows和Linux中使用Ctrl + D可以对相同的单词进行多词编辑。

使用CMD + D for Mac。

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

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

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

在Windows中,下面的组合适合我:

ctrl+shift+alt+向下箭头 ctrl+shift+alt+up箭头

只用两步就解决了!

按 + F Alt + Enter

它等于Sublime Text的Alt + F3。


注:对于macOS,⌘+ F后面加“+ Enter”相当于Sublime Text的⌃+⌘+ G。