Visual Studio代码中的多行编辑

本文翻译自:Multiline editing in Visual Studio Code

Is it possible to enable multiline editing like in Sublime Text ? 是否可以像Sublime Text一样启用多行编辑?

For example, press Ctrl to place additional cursor carets and being able to write/delete on multiple places in the document at one time. 例如,按Ctrl键可以放置其他光标插入符,并且可以一次在文档中的多个位置写入/删除。


#1楼

参考:https://stackoom.com/question/222Cm/Visual-Studio代码中的多行编辑


#2楼

On Windows, you hold Ctrl + Alt while pressing the up or down arrow keys to add cursors. 在Windows上,按住Ctrl + Alt,同时按向上或向下箭头键添加光标。 On Mac and Linux, the equivalents are ⌥ Opt + ⌘ Cmd + / and Shift + Alt + / , respectively. 在Mac和Linux上,等效项分别为⌥Opt + ⌘Cmd + / Shift + Alt + /

Note that third-party software may interfere with these shortcuts, preventing them from working as intended (particularly Intel's HD Graphics software on Windows; see comments for more details). 请注意,第三方软件可能会干扰这些快捷方式,从而阻止它们按预期工作(尤其是Windows上的英特尔高清显卡软件;有关详细信息,请参阅注释)。

If you experience this issue, you can either disable the Intel/other software hotkeys, or modify the VS Code shortcuts (described below). 如果遇到此问题,可以禁用Intel /其他软件热键,或修改VS Code快捷方式(如下所述)。

Press Esc to reset to a single cursor. Esc键重置为单个光标。

Visual Studio Code中的多行游标

Or, as Isidor Nikolic points out , you can hold Alt and left click to place cursors arbitrarily. 或者, 正如Isidor Nikolic指出的那样 ,您可以按住Alt并左键单击以任意放置光标。

在Visual Studio Code中任意放置多行游标

You can view and edit keyboard shortcuts via: 您可以通过以下方式查看和编辑键盘快捷键:

File → Preferences → Keyboard Shortcuts 文件→首选项→键盘快捷键

Documentation: 文档:

https://code.visualstudio.com/docs/customization/keybindings https://code.visualstudio.com/docs/customization/keybindings

Official VS Code Keyboard shortcut cheat sheets: 官方VS Code键盘快捷键备忘单:

https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf https://code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf https://code.visualstudio.com/shortcuts/keyboard-shortcuts-linux.pdf


#3楼

You can just Alt + click for additional cursors. 您只需按住Alt键并单击其他游标即可。 And as already mentioned, Ctrl + Alt + or . 如前所述, Ctrl + Alt +


#4楼

On Mac it is: 在Mac上它是:

Option + Command while pressing the up or down arrow keys. 按下向上或向下箭头键时按Option + Command


#5楼

(Windows 10 pro x64) Here have some ways! (Windows 10专业版x64)这里有一些方法!

  1. Alt + click 按住Alt并 单击

  2. Alt + Ctrl + up / down Alt + Ctrl + 向上 / 向下

  3. Keybindings: Ctrl + click (??? it doesn't work!) 键绑定: Ctrl + click (???它不起作用!)

在此输入图像描述


#6楼

I think it depends on your Visual Studio Code version. 我认为这取决于您的Visual Studio代码版本。

Mine is Linux version Visual Studio Code 1.7.2. 我的是Linux版Visual Studio Code 1.7.2。

                                     "when": "editorTextFocus" },
{ "key": "shift+alt+up",          "command": "editor.action.insertCursorAbove",
                                     "when": "editorTextFocus" },
{ "key": "ctrl+shift+down",       "command": "editor.action.insertCursorBelow",
                                     "when": "editorTextFocus" },
{ "key": "shift+alt+down",        "command": "editor.action.insertCursorBelow",
                                     "when": "editorTextFocus" }```

The point is the shortcuts are not same in all machines, so you should check your configuration. Go to menu:

> Menu *File* → *Preferences* → *Keyboard Shortcuts*

Search for `editor.action.insertCursorAbove` and `editor.action.insertCursorBelow` and see your current configurations. You may change them if they conflict with operating system's shortcut keys.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值