本文共 4909 字,大约阅读时间需要 16 分钟。
本文翻译自:
How can you create multiple cursors when editing in VS Code? 在VS Code中编辑时如何创建多个游标? I'm interested in both macOS and Windows. 我对macOS和Windows都很感兴趣。
参考:
Press Alt and click. 按Alt并单击。 This works on Windows and Linux*, and it should work on Mac, too. 这适用于Windows和Linux *,它也适用于Mac。
More multi-cursor features are now available in Visual Studio Code 0.2: Visual Studio Code 0.2现在提供了更多的多光标功能:
Multi cursor improvements 多光标改进
Ctrl+D ( Cmd+D on Mac) selects next occurrence of word under cursor or of the current selection Ctrl + D (Mac上的Cmd + D )选择光标下或当前选择下的下一个字 Ctrl+K Ctrl+D moves last added cursor to next occurrence of word under cursor or of the current selection Ctrl + K Ctrl + D将最后添加的光标移动到光标或当前选择下的下一个字 The commands use matchCase by default. 默认情况下,这些命令使用matchCase。 If the find widget is open, then the find widget settings (matchCase / matchWholeWord) will be used for determining the next occurrence 如果查找窗口小部件已打开,则查找窗口小部件设置(matchCase / matchWholeWord)将用于确定下一次出现 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. Ctrl + U (Mac上为Cmd + U )撤消上一个光标操作,因此如果添加了太多光标或出错,可以按Ctrl + U (Mac上为Cmd + U )返回上一个光标状态。 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 (ie select 300 lines and only 80 fit in the viewport). 向上或向下添加光标( Ctrl + Alt +向上 / Ctrl + Alt +向下 )(Mac 上的Cmd + Alt +向上 / Cmd + Alt +向下 )现在显示最后添加的光标,以便更容易使用多个游标一次超过1个视口高度(即选择300行,只有80个适合视口)。This makes it a lot easier to introduce multiple cursors 这使得引入多个游标变得更加容易
* Linux drag-window conflict: * Linux拖窗冲突:
Some distros (eg Ubuntu) assign window dragging to Alt+LeftMouse , which will conflict with VSCode. 一些发行版(例如Ubuntu)将窗口拖动分配给Alt + LeftMouse ,这将与VSCode冲突。
So, recent versions of VSCode let you toggle between Alt+LeftMouse and Ctrl+LeftMouse under the Selection menu, as detailed in . 因此,最新版本的VSCode允许您在“选择”菜单下的Alt + LeftMouse和Ctrl + LeftMouse之间切换,详见 。
Alternately, you could change your OS key bindings using
gsettings
as mentioned in . 或者,您可以使用提到的gsettings
更改操作系统键绑定。
Ctrl + Alt + ⬇ / ⬆ add cursors above and below the current line. Ctrl + Alt + ⬇/⬆在当前行的上方和下方添加光标。 Still nowhere near as good as sublime or brackets though. 尽管如此,仍然远不如崇高或括号那么好。 I can't see anything equivalent to Ctrl + D in sublime in the keyboard shortcuts file. 在键盘快捷方式文件中,我无法在sublime中看到与Ctrl + D等效的内容。
There is no binding for exactly what you want. 对于你想要的东西没有任何约束力。
The only thing that comes close is Ctrl + F2 which will select all of them at once. 唯一接近的是Ctrl + F2 ,它将立即选择所有这些。
You can bind it to Ctrl + D doing the following: 您可以将其绑定到Ctrl + D,执行以下操作:
File > Preferences > Keyboard Shortcuts
单击File > Preferences > Keyboard Shortcuts
You should see a pane full of the current bindings and on the right a list of custom bindings 您应该看到一个窗格,其中包含当前绑定,右侧是自定义绑定列表 It should look something like this: 它应该看起来像这样:
// Place your key bindings in this file to overwrite the defaults[{ "key": "ctrl+d", "command": "editor.action.changeAll", "when": "editorTextFocus" }]
I had problem with ALT key, fix is to change alt+click
as a Gnome hotkey which clobbers multi-cursor select in VSCode, to super+click
by running: 我有ALT键的问题,修复是更改alt+click
作为Gnome热键,在VSCode中使用多个光标选择,通过运行来super+click
:
gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier ""
Source: 资料来源: :
New version (Visual Studio 0.3.0) support more multi cursor feature. 新版本(Visual Studio 0.3.0)支持更多的多光标功能。
Multi-cursorHere'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).
And short cut of select multi cursor change into cmd + d(it's same as Sublime Text. lol) 选择多光标的快捷方式改为cmd + d(与Sublime Text相同。大声笑)
We can expect that next version supports more convenient feature about multi cursor ;) 我们可以期待下一版本支持更多关于多光标的方便功能;)
转载地址:http://bpcnb.baihongyu.com/