使用键盘选择VSCode列

And*_*tti 9 keyboard-shortcuts text-editor visual-studio-code

有没有办法只使用键盘进行这种选择?

在此输入图像描述

使用常规Visual Studio,我会使用Shift+ Alt+ Arrows来选择这些列.不幸的是它在VSCode中不起作用.

Ull*_*loo 12

默认情况下,这是Ctrl + Shift + Alt + Arrow.

如果您想重新绑定它以与Visual Studio对齐,请将其放入keybindings.json:

{
    "key": "shift+alt+down",
    "command": "cursorColumnSelectDown",
    "when": "editorTextFocus"
},
{
    "key": "shift+alt+left",
    "command": "cursorColumnSelectLeft",
    "when": "editorTextFocus"
},
{
    "key": "shift+alt+pagedown",
    "command": "cursorColumnSelectPageDown",
    "when": "editorTextFocus"
},
{
    "key": "shift+alt+pageup",
    "command": "cursorColumnSelectPageUp",
    "when": "editorTextFocus"
},
{
    "key": "shift+alt+right",
    "command": "cursorColumnSelectRight",
    "when": "editorTextFocus"
},
{
    "key": "shift+alt+up",
    "command": "cursorColumnSelectUp",
    "when": "editorTextFocus"
}
Run Code Online (Sandbox Code Playgroud)

这将与复制线路或使用智能选择增长/缩小的默认功能冲突,因此您可以添加此功能以交换要求Control:

,
{
    "key": "ctrl+shift+alt+down",
    "command": "editor.action.copyLinesDownAction",
    "when": "editorTextFocus && !editorReadonly"
},
{
    "key": "ctrl+shift+alt+up",
    "command": "editor.action.copyLinesUpAction",
    "when": "editorTextFocus && !editorReadonly"
},
{
    "key": "ctrl+shift+alt+right",
    "command": "editor.action.smartSelect.grow",
    "when": "editorTextFocus"
},
{
    "key": "ctrl+shift+alt+left",
    "command": "editor.action.smartSelect.shrink",
    "when": "editorTextFocus"
}
Run Code Online (Sandbox Code Playgroud)

  • 在 MACOS 上:Command + Shift + Alt/Option + 箭头。 (7认同)
  • 自从我开始使用 VS Code 以来,这是我最大的烦恼之一。这使得它更加有用,你是最好的! (2认同)

小智 10

您可以使用菜单“文件”->“首选项”->“键盘快捷键”查看当前的键盘快捷键。然后通过“cursorColum”搜索在此输入图像描述


Lov*_*ell 6

以下是使用 vscode 对我有用的内容:

Version: 1.39.2 (user setup)
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:35:18.241Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362
Run Code Online (Sandbox Code Playgroud)
  1. 将光标放在块的左上角进行选择
  2. 按住 ctrl-alt-shift
  3. 多次按下向下箭头
  4. 多次按右箭头

当第 3 步是按向右箭头时,它对我不起作用。


Abd*_*ari 5

您可以通过多种方式进行列选择,

  • 正如您所指出的,将光标置于第一列的第一个单词的开头(左侧)并按住,Alt + Shift然后Right Arrow选择顶行(Ctrl + Shift如果上一个组合键不起作用,请尝试)。按下 键后,继续按Down Arrow键选择列。

  • 将光标置于第一列第一个单词的开头(左侧) 按住Alt + Shift并重复按Down Arrow 可添加更多光标。(某些版本的 VSCode 也使用Ctrl+Shift)一旦添加了光标,通过一个简单的选择单词Shift + Right Arrow

  • Ctrl+D选择当前光标下的单词的下一次出现。

  • Ctrl+Shift+L选择光标下当前选择的所有单词,无论这些单词是在光标上方还是下方。