簡體   English   中英

VSCode 用鍵盤選擇列

[英]VSCode column selection with keyboard

有什么方法可以使用鍵盤進行這種選擇?

在此處輸入圖像描述

使用常規的 Visual Studio,我會使用Shift + Alt + Arrows來選擇這些列。 不幸的是,它在 VSCode 中不起作用。

默認情況下,這是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"
}

這將與復制線或使用智能選擇增長/收縮的默認功能沖突,因此您可以添加它以交換那些需要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"
}

以下是使用 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 步是按向右箭頭時,它對我不起作用。

您可以通過多種方式進行列選擇,

  • 正如您所指出的,將光標置於第一列的第一個單詞的開頭(左側),按住Alt + Shift,然后按右箭頭鍵選擇頂行(如果前一個組合鍵不起作用,請嘗試Ctrl + Shift )。 按下按鍵后,按向下箭頭鍵繼續選擇列。

  • 將光標置於第一列第一個單詞的開頭(左側)按住Alt + Shift並重復按向下箭頭以添加更多光標 (某些版本的 VSCode 也使用Ctrl+Shift代替)添加光標后,通過簡單的Shift + 右箭頭選擇單詞

  • Ctrl+D選擇當前光標下出現的下一個詞。

  • Ctrl+Shift+L選擇光標下當前選擇的所有出現的詞,無論這些詞是在光標上方還是下方。

您可以使用菜單“文件”->“首選項”->“鍵盤快捷鍵”查看當前的鍵盤快捷鍵。 然后通過“cursorColum”搜索在此處輸入圖片說明

它需要安裝Visual Studio Keymap

  1. 打開視圖 -> 擴展(或Ctrl + Shift + X
  2. 搜索Visual Studio 鍵盤映射
  3. 安裝並重啟 VSCode

現在可以通過Shift + Alt + Arrows 進行列選擇。

請參閱Visual Studiohttps://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_43.md#column-selection-mode 等列選擇

列選擇模式可能會在 v1.43 或即將推出,請參閱上面鏈接中的演示。 它將是“ Selection菜單中的一個選項。

使用鼠標效果最佳,但也可以使用快捷鍵:

選中此項時,使用鼠標選擇將創建列選擇,Shift+箭頭鍵和 Shift+Page Up/Down 鍵也將創建列選擇。

我必須執行以下操作:

  1. 打開鍵綁定設置: ctrl+k,ctrl+s
  2. 刪除Notebook: Copy Cell <Up/Down>鍵綁定Notebook: Copy Cell <Up/Down>Copy Line <Up/Down>
  3. 搜索cursorColumnSelect <Up/Down>鍵綁定。
  4. 將顯示When: textInputFocus的綁定重新分配給Shift+Alt+<arrow keys>

Sublime text 有這個 select 列的快捷方式:Ctrl + Alt + Up 或 Ctrl + Alt + Down。

因此,將此擴展添加到 VSCode:Sublime Text Keymap and Settings Importer。

您可以使用快捷方式並完成..

VSC 中的默認鍵綁定...

CMD ALT SHIFT ARROW (Mac)

CTRL ALT SHIFT箭頭(PC?)

這個答案適用於那些喜歡默認鍵盤快捷鍵的人。 我更喜歡它們,因為當我使用其他機器和在新 Mac 上啟動時,它們可以(開箱即用)工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM