在VS代码中创建多个光标的键盘快捷键是什么?


当前回答

Cmd+Option+Shift⬇ / ⬆ 在最新的VSCode 1.29.1和最新的OSX High Sierra 10.13.6,Macbook Pro上为我工作。

这将在屏幕上向上/向下添加一条垂直线,就像Sublime文本中的Option+单击/垂直拖动一样。

要在文件中的任意位置添加多个光标,包括同一行上的多个,请执行Cmd(或Option)+单击本视频中所示的任意位置。您也可以搜索重复多次的文本(Cmd+F),然后按Option+Retur在每个单词的末尾添加光标。

其他回答

首先转到“键盘快捷键”,您可以按Cmd+k然后按Cmd+s,或者对于Windows,按Ctrl+k然后按Ctrl+s。

到达后,搜索“在上方添加光标”和“在下方添加光标”。您甚至可以为它们分配自己的密钥绑定。

在Ubuntu上,为了启用多光标单击,您需要首先通过运行下面的命令重新分配Alt+click。这是因为默认情况下,Ubuntu使用快捷方式本身并具有优先权。

> gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier "<Super>"

在XFCE上,转到应用程序->设置->设置编辑器->xfwm4->easy_click(禁用值)

现在您可以使用Alt+Click插入光标

我还在“设置”->“窗口管理器”->“键盘”中禁用了L/R工作区(ctrl+alt+L/R)设置

可以根据“选择”菜单执行以下操作:

根据需要按住Alt+Ctrl+向上箭头/Alt+Ctrl+向下箭头以创建足够的光标,然后可以使用Ctrl+D来展开选择。

https://code.visualstudio.com/Updates

新版本(Visual Studio 0.3.0)支持更多的多光标功能。

Multi-cursor
Here's multi-cursor improvements that we've made.

⌘D selects the word at the cursor, or the next occurrence of the current selection.
⌘K ⌘D moves the last added cursor to next occurrence of the current selection.
The two actions pick up the matchCase and matchWholeWord settings of the find widget.
⌘U undoes the last cursor action, so if you added one cursor too many or made a mistake, press ⌘U to return to the previous cursor state.
Insert cursor above (⌥⌘↑) and insert cursor below (⌥⌘↓) now reveals the last added cursor, making it easier to work with multi-cursors spanning more than one screen height (i.e., working with 300 lines while only 80 fit in the screen).

选择多光标的快捷方式更改为cmd+d(与Sublime Text.lol相同)

我们可以预期,下一个版本支持关于多光标的更方便的功能;)