本文翻译自:Multiple cursors in Visual Studio Code [closed]

How can you create multiple cursors when editing in VS Code? 在VS Code中编辑时如何创建多个游标? I'm interested in both macOS and Windows. 我对macOS和Windows都很感兴趣。


#1楼

参考:https://stackoom.com/question/21gGd/Visual-Studio代码中的多个游标-关闭


#2楼

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 another answer . 因此,最新版本的VSCode允许您在“选择”菜单下的Alt + LeftMouse和Ctrl + LeftMouse之间切换,详见另一个答案 。

Alternately, you could change your OS key bindings using gsettings as mentioned in another answer . 或者,您可以使用另一个答案中提到的gsettings更改操作系统键绑定。


#3楼

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等效的内容。


#4楼

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,执行以下操作:

  • Click on 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 您应该看到一个窗格,其中包含当前绑定,右侧是自定义绑定列表
  • In the current bindings, search for Ctrl + F2 and copy that whole line and paste it into the right pane. 在当前绑定中,搜索Ctrl + F2并复制整行并将其粘贴到右窗​​格中。
  • You might have to remove the comma at the end and then change Ctrl + F2 to Ctrl + D and then save the file. 您可能必须删除末尾的逗号,然后将Ctrl + F2更改为Ctrl + D ,然后保存文件。

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" }
]

#5楼

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 "<Super>"

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


#6楼

https://code.visualstudio.com/Updates https://code.visualstudio.com/Updates

New version (Visual Studio 0.3.0) support more multi cursor feature. 新版本(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).

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 ;) 我们可以期待下一版本支持更多关于多光标的方便功能;)

Visual Studio代码中的多个游标[关闭]相关推荐

  1. 在Visual Studio代码中显示空白字符

    本文翻译自:Show whitespace characters in Visual Studio Code Is it possible to show whitespace characters, ...

  2. 如何在Visual Studio代码中隐藏侧栏中的某些文件?

    本文翻译自:How do I hide certain files from the sidebar in Visual Studio Code? Using Microsoft's Visual S ...

  3. vscode 注释多行代码_如何在Visual Studio Code中注释多行?

    我找不到在Visual Studio Code中注释和取消注释多行代码的方法. 是否可以使用某些快捷方式在Visual Studio Code中注释和取消注释多行? 如果是,该怎么办? 当其中一行已被 ...

  4. visual studio css大纲,Visual Studio代码CSS缩进和格式化

    11 个答案: 答案 0 :(得分:85) 是的,请尝试安装vscode-css-formatter extension.它只是添加了格式.css文件的功能,并且快捷方式保持不变Alt+Shift+F ...

  5. 如何在Visual Studio Code中编译C ++代码

    PS: This was published on my Blog here. PS:这已发布在我的Blog 此处 . C++ is a statically-typed, free-form, (u ...

  6. 一起谈.NET技术,Visual Studio 2010 中的代码约定设置

    软件约定称为代码约定,通过这一约定可以表示代码正常工作所需的正式条件. 如果方法未按预期收到数据或生成的数据不符合预期的后置条件,代码约定将导致代码引发异常. 有关前置条件和后置条件的概述,您可能需要 ...

  7. 详述Visual Studio 代码远程开发扩展中的远程命令执行漏洞

     聚焦源代码安全,网罗国内外最新资讯! 编译:代码卫士 Visual Studio 代码远程开发扩展(Code Remote Development Extension) 1.50 未能在将其用作 s ...

  8. 您如何计算Visual Studio解决方案中的代码行?

    是否可以在整个解决方案中找到代码行数? 我听说过MZ-Tools ,但是有没有开源的? #1楼 你可以使用: SCLOCCount http://www.dwheeler.com/sloccount/ ...

  9. 直接在Visual Studio代码编辑器中加密字符串文件

    String encryption is used everywhere in desktop & mobile software. You might not even know about ...

最新文章

  1. graphql是什么_为什么GraphQL是避免技术债务的关键
  2. Maven 的获取、安装与环境变量设置方法
  3. php从内存中获取源码_【PHP7源码分析】PHP内存管理
  4. 成功解决torch\cuda\__init__.py“, line 208, in check_error raise Cuda Error(res) torch.cuda.Cuda Error: C
  5. SSL与OpenSSL关系介绍
  6. PTA-1011——World Cup Betting
  7. 如何在 ASP.NET Core 中为 gRPC 服务添加全局异常处理 ?
  8. +++程序员高手修炼之路
  9. SAP License:SAP记账码
  10. 入行||转行软件测试?写给迷惘的你
  11. 连载四:PyCon2018|恶意域名检测实例(附源码)
  12. 逻辑运算符 用法解释
  13. 激活函数:双曲正切函数 tanh(x)
  14. excel相乘再相加_excel现乘积再求和如何自动生成
  15. STEP2——《数据分析:企业的贤内助》重点摘要笔记(三)——数据录入
  16. 社工库寻求帮助可以下载
  17. ValueError: The field admin.LogEntry.user was declared with a lazy reference to ‘MyApp.sysusers‘
  18. 待得天晴花已老,不如携手雨中看
  19. Error: The apk for your currently selected variant (app-release-unsigned.apk) is not signed. Please
  20. 哥德巴赫猜想两种题目解法

热门文章

  1. Java的多线程问题追根溯源。
  2. Android Popwindow 使用
  3. Android String.xml 批量翻译工具 | Android string.xml 各国语言转换
  4. Linux—进程管理
  5. Android防止按钮连续点击
  6. Glide 框架解析
  7. (0063)iOS开发之SVN server的搭建
  8. python大数据搜索_python语言-用 Python 实现一个大数据搜索引擎
  9. Java中break、Continue、reutrn总结
  10. 用存储过程创建的分页