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

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


当前回答

我正在使用Sublime Text keymap,顶部答案提供的键绑定似乎不工作:(可能是Visual Studio代码和Sublime keymap之间的一些冲突。

@Han推荐的按键绑定很适合我(非常感谢!):

按Ctrl + Shift +上/下进入多行光标模式 使用Esc退出


下面是一个使用Emmet和多行游标的小例子(通过上面列出的这些键绑定启用和禁用):

其他回答

我认为这取决于你的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中,下面的组合适合我:

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

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

Ctrl + Alt + Shift +下/上

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

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

在Mac上是:

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

在Visual Studio Code中,只需按Alt键并将光标放在编辑位置(你想编辑的地方),然后右键单击选择。