Visual Studio代码中有多个游标

有没有人有任何运气与新的“Visual Studio代码”上的多个游标

请在Mac和Windows上分享您的发现。

更新

Visual Studio代码0.2中现在提供了更多的多光标function:

多游标改进
Ctrl + Dselect光标或当前select下的单词的下一个出现位置
Ctrl + K Ctrl + D将最后添加的光标移动到光标下方或当前所选内容的下一个出现位置
这些命令默认使用matchCase。 如果查找小部件是打开的,那么将使用查找小部件设置(matchCase / matchWholeWord)来确定下一个事件
Ctrl + U取消最后的光标操作,所以如果你添加的光标太多或者出错了,可以按Ctrl + U返回到前一个光标状态。 向上或向下添加光标( Ctrl + Alt + Up / Ctrl + Alt + Down )现在可以显示最后添加的光标,以便一次处理多个视口高度的多个光标(例如,select300行,仅select80行适合在视口中)。

这使得引入多个游标变得更容易

按下Alt并点击。 在Windows和Linux *上工作,也应该在Mac上工作。

*一些发行版(如Ubuntu)分配窗口拖动到Alt + LeftMouse ,这将与VSCode冲突。 你可以用其他答案中提到的gsettings来改变它。

我有问题的ALT键,修复是改变alt+click作为一个Gnome的热键,在VSCode中多重光标select, super+click运行:

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

资料来源: http : //2buntu.com/articles/1529/visual-studio-code-comes-to-linux/

VS代码中的多字(和多行)游标/select

多字:

Windows / OS X:

  • Ctrl + Shift + L / Cmd + Shift + Lselect当前突出显示的单词的所有实例
  • Ctrl + D / Cmd + Dselect下一个实例…之后的实例…等等

多行:

对于多行select, Ctrl + Alt + Down / Cmd + Alt + Down会将您的select或光标位置延伸到下一行。 Ctrl + Right / Cmd + Right将移动到每一行的末尾,不pipe多长时间。 要逃避多行select,请按Esc键

请参阅VS代码键盘 (操作系统敏感)

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

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

2017年5月
从版本1.13开始,使用Ctrl / Cmd + Click添加多个游标

VSCode开发人员已经引入了一个新的设置, editor.multiCursorModifier ,来改变应用多个游标到Cmd的修改键。 Click macOS和Ctrl + Click Windows和Linux。 这可以让来自其他编辑器(如Sublime Text或Atom)的用户继续使用他们熟悉的键盘修改器。

该设置可以设置为:

  • ctrl/Cmd – 映射到Windows上的Ctrl和macOS上的Cmd
  • alt – 现有的默认Alt

在“ Selection菜单中还有一个新的菜单项“使用Ctrl + Click ”可以快速切换此设置。 在这里输入图像说明

转到定义”和“ 打开链接”手势也将尊重此设置,并进行适应性修改,以免发生冲突。 例如,当设置为ctrl/Cmd ,可以使用Ctrl / Cmd + Click添加多个游标,可以使用Alt + Click调用打开链接或进入定义。

通过修复问题#2106,现在可以通过在现有select之上使用相同的手势来移除光标。

尝试Ctrl + Alt + Shift + ⬇/⬆ ,不用鼠标,或按住“alt”并点击所有你想要的行。

obs:在Windows上testing。

从Visual Studio Code 0.10.9开始,您现在可以通过select多行来执行从选定行创build多个光标 ,然后按Shift + Alt + I

注意:这与Sublime Text的Ctrl + Shift + Lfunction类似。

来源: https : //code.visualstudio.com/updates/vJanuary#_thank-you
相关PR: https : //github.com/Microsoft/vscode/pull/1479

https://code.visualstudio.com/Updates

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

 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 (ie, working with 300 lines while only 80 fit in the screen). 

select多光标切换到cmd + d(与Sublime Text相同lol)

我们可以期待下一个版本支持多游标的更方便的function;)

在没有鼠标的Visual Studio中: Alt + Shift + {Arrow}

没有什么约束你想要的。

唯一接近的是Ctrl + F2 ,它将一次全部选中。

您可以将其绑定到Ctrl + D,执行以下操作:

  • 点击File > Preferences > Keyboard Shortcuts
    您应该看到一个完整的当前绑定窗格,右侧是一个自定义绑定列表
  • 在当前绑定中,searchCtrl + F2并复制整行,并将其粘贴到右侧窗格中。
  • 您可能需要在最后删除逗号,然后将Ctrl + F2更改为Ctrl + D ,然后保存该文件。

它应该看起来像这样:

 // Place your key bindings in this file to overwrite the defaults [ { "key": "ctrl+d", "command": "editor.action.changeAll", "when": "editorTextFocus" } ] 

在XFCE上,进入Applications -> Settings -> Configuration manager -> Settings editor - > xfwm4 -> easy_click(disable value)

现在,您可以使用Alt + Click Insert Cursor

我刚刚将我的语言环境(非英文)翻译成英文,所以在英文环境中可能会有所不同。

我还禁用了Settings -> Window manager -> Keyboard左/右工作区( ctrl + alt + L / R

Ctrl + Alt + ⬇/⬆在当前行的上下添加光标。 尽pipe如此,仍然远不及崇高或括号。 在键盘快捷方式文件中,我看不到任何等同于Ctrl + D的东西。

在我的XFCE(版本4.12),它在Settings -> Window Manager Tweaks -> Accessibility

有一个下拉字段Key used to grab and move windows: ,将其设置为None

Alt + Click现在在VS代码中添加更多的游标。

您可以按照select菜单执行以下操作:

VS代码中选择菜单的屏幕截图

按住Alt + Ctrl +向上箭头 / 按住Alt + Ctrl +向下箭头按照需要创build足够的光标,然后按Ctrl + D可以用来展开select。

Alt + Command + Shift会将光标添加到您select的下一个实例。 例如一个variables或函数名称

Alt +点击。 它在Windows中工作。

详细信息: Visual Studio代码文档

在Ubuntu-MATE上同样的问题,但在这里你解决它:

 gsettings set org.mate.Marco.general mouse-button-modifier "<Super>" 

Alt + Click在OSX中工作。 代码版本1.14.2