如何在 Visual Studio Code 中创建多个游标 [英] How can you create multiple cursors in Visual Studio Code

查看:45
本文介绍了如何在 Visual Studio Code 中创建多个游标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What are the keyboard shortcuts for creating multiple cursors in VS Code?

推荐答案

Alt 并单击.这适用于 Windows 和 Linux*,也适用于 Mac.

Press Alt and click. This works on Windows and Linux*, and it should work on Mac, too.

Visual Studio Code 0.2 现在提供更多多光标功能:

More multi-cursor features are now available in Visual Studio Code 0.2:

多光标改进
Ctrl+D(在 Mac 上为 Cmd+D)选择光标下或当前选择的下一个单词
Ctrl+K Ctrl+D 将最后添加的光标移动到光标下或当前选择的下一个词处
这些命令默认使用 matchCase.如果查找小部件已打开,则将使用查找小部件设置(matchCase/matchWholeWord)来确定下一次出现
Ctrl+U(Mac 上为 Cmd+U)撤消最后一次光标操作,因此如果您添加的光标过多或出错,您可以按 Ctrl+U(Mac 上为 Cmd+U)返回到先前的光标状态.向上或向下添加光标 (Ctrl+Alt+Up/Ctrl+Alt+Down) (Cmd+Alt+Up/Cmd+Alt+Down(在 Mac 上)现在会显示最后添加的光标,以便更轻松地一次在 1 个以上的视口高度上使用多个光标(即选择 300 行,而视口中只有 80 行).

Multi cursor improvements
Ctrl+D (Cmd+D on Mac) selects next occurrence of word under cursor or of the current selection
Ctrl+K Ctrl+D moves last added cursor to next occurrence of word under cursor or of the current selection
The commands use matchCase by default. If the find widget is open, then the find widget settings (matchCase / matchWholeWord) will be used for determining the next occurrence
Ctrl+U (Cmd+U on Mac) undoes the last cursor action, so if you added a cursor too many or made a mistake, you can press Ctrl+U (Cmd+U on Mac) to go back to the previous cursor state. Adding cursor up or down (Ctrl+Alt+Up / Ctrl+Alt+Down) (Cmd+Alt+Up / Cmd+Alt+Down on Mac) now reveals the last added cursor to make it easier to work with multiple cursors on more than 1 viewport height at a time (i.e. select 300 lines and only 80 fit in the viewport).

* Linux 拖拽窗口冲突:

* Linux drag-window conflict:

某些发行版(例如 Ubuntu)将窗口拖动分配给 Alt+LeftMouse,这会与 VSCode 冲突.

Some distros (e.g. Ubuntu) assign window dragging to Alt+LeftMouse, which will conflict with VSCode.

因此,最新版本的 VSCode 允许您在选择"菜单下的 Alt+LeftMouseCtrl+LeftMouse 之间切换,详情请参见 另一个答案.

So, recent versions of VSCode let you toggle between Alt+LeftMouse and Ctrl+LeftMouse under the Selection menu, as detailed in another answer.

或者,您可以使用 gsettings 更改操作系统键绑定,如另一个答案中所述.

Alternately, you could change your OS key bindings using gsettings as mentioned in another answer.

这篇关于如何在 Visual Studio Code 中创建多个游标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆