【问题标题】:VSCode column selection with keyboardVSCode 用键盘选择列
【发布时间】:2017-04-19 17:39:39
【问题描述】:

有什么方法可以仅使用键盘进行这种选择?

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

【问题讨论】:

    标签: visual-studio-code keyboard-shortcuts text-editor


    【解决方案1】:

    默认情况下,这是 Ctrl + Shift + Alt + 箭头。

    如果您想重新绑定它以与 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"
    }
    

    这将与复制一行或使用智能选择扩大/缩小的默认功能冲突,因此您可以添加它以将那些交换为需要 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"
    }
    

    【讨论】:

    • 自从我开始使用 VS Code 以来,这一直是我最大的烦恼之一。这使它更有用,你最好!
    • 在 MACOS 上:Command + Shift + Alt/Option + 箭头。
    【解决方案2】:

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

    • 如您所述,将光标放在第一列第一个单词的开头(左侧)按住 Alt + Shift,然后按住 右箭头选择第一行 (如果之前的组合键不起作用,请尝试 Ctrl + Shift)。按住按键继续按 向下箭头 键选择列。

    • 将光标置于第一列第一个单词的开头(左侧) 按住 Alt + Shift 并反复按 向下箭头 添加更多光标。 (某些版本的 VSCode 也使用 Ctrl+Shift 代替) 添加光标后,通过简单的 Shift + 右箭头

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

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

    【讨论】:

    • 他们都没有在这里工作。我仍然不能像普通的 Visual Studio ALT + 箭头那样做。
    • @AndréLuizCarletti 你可能有旧版本的 VSCode。
    • 我使用的是 1.11.2 版。日期 2017-04-13。我是否需要任何特殊插件才能使快捷方式正常工作?
    【解决方案3】:

    这就是 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
    
    1. 将光标放在要选择的块的左上角
    2. 按住 ctrl-alt-shift
    3. 按向下箭头任意多次
    4. 按右箭头任意多次

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

    【讨论】:

      【解决方案4】:

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

      【讨论】:

      • 在 Mac OS 上,“首选项”位于菜单“代码”而不是“文件”中。
      【解决方案5】:

      需要安装Visual Studio Keymap:

      1. 打开View -> Extensions(或Ctrl + Shift + X)
      2. 搜索 visual studio 键盘映射
      3. 安装并重启 VSCode

      现在可以通过 Shift + Alt + Arrows 选择列。

      【讨论】:

        【解决方案6】:

        见Column selection like Visual Studio和https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_43.md#column-selection-mode

        列选择模式可能会在 v1.43 或很快推出,请参阅上面链接中的演示。这将是Selection 菜单中的一个选项。

        最适合使用鼠标,但也可以使用快捷键:

        选中此项后,使用鼠标选择将创建一个列 选择和 Shift+箭头键和 Shift+Page Up/Down 键也将 创建列选择。

        【讨论】:

          【解决方案7】:

          我必须做到以下几点:

          1. 打开键绑定设置:ctrl+k,ctrl+s。
          2. 删除Notebook: Copy Cell <Up/Down> 和Copy Line <Up/Down> 的键绑定。
          3. 搜索cursorColumnSelect <Up/Down> 的键绑定。
          4. 将When: textInputFocus 的绑定重新分配给Shift+Alt+<arrow keys>。

          【讨论】:

            猜你喜欢
            • 2019-03-10
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2022-01-03
            • 1970-01-01
            • 1970-01-01
            • 2015-06-16
            • 1970-01-01
            相关资源
            最近更新 更多