简体   繁体   中英

Why does shift/alt keyboard combination work for default bindings but not my custom ones? (VS Code)

In Fedora Linux/Gnome and VS Code 1.36.1, the original bindings of "key": "shift+alt+right" work fine, but I can't get my custom ones to do anything.

I am adding to keybindings.json and tried various keys.

When I use the Keyboard short cuts and recording keys mode it picks them up fine.

// expand/shrink selection vim style
  {
    "key": "shift+alt+l",
    "command": "editor.action.smartSelect.expand",
    "when": "editorTextFocus"
  },
  {
    "key": "shift+alt+h",
    "command": "editor.action.smartSelect.shrink",
    "when": "editorTextFocus"
  },

There is some kind of intermittent bug, it now works as written in the question. Here is the full config (working today) in case you want this functionality and it messes you about too!

// Place your key bindings in this file to overwrite the defaults
[
  // capslock delete
  {
    "key": "capslock",
    "command": "deleteLeft",
    "when": "textInputFocus && !editorReadonly"
  },
  // expand/shrink selection vim style
  {
    "key": "shift+alt+l",
    "command": "editor.action.smartSelect.expand",
    "when": "editorTextFocus"
  },
  {
    "key": "shift+alt+h",
    "command": "editor.action.smartSelect.shrink",
    "when": "editorTextFocus"
  },
  // navigate back forward position
  {
    "key": "alt+left",
    "command": "workbench.action.navigateBack"
  },
  {
    "key": "alt+right",
    "command": "workbench.action.navigateForward"
  },
  // terminal style jump back and forward over words
  {
    "key": "alt+b",
    "command": "cursorWordStartLeft",
    "when": "textInputFocus"
  },
  {
    "key": "alt+f",
    "command": "cursorWordEndRight",
    "when": "textInputFocus"
  },
  // terminal style delete back and forward over words
  {
    "key": "alt+capslock",
    "command": "deleteWordLeft",
    "when": "textInputFocus && !editorReadonly"
  },
  {
    "key": "alt+d",
    "command": "deleteWordRight",
    "when": "textInputFocus && !editorReadonly"
  },
  // Lists with vim style shortcuts
  {
    "key": "alt+j",
    "command": "list.focusDown",
    "when": "listFocus"
  },
  {
    "key": "alt+k",
    "command": "list.focusUp",
    "when": "listFocus"
  },
  // Autosuggest with vim style shortcuts
  {
    "key": "alt+j",
    "command": "selectNextSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
  },
  {
    "key": "alt+k",
    "command": "selectPrevSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible"
  },
  // Quick open with vim style shortcuts
  {
    "key": "alt+j",
    "command": "workbench.action.quickOpenSelectNext",
    "when": "!editorFocus"
  },
  {
    "key": "alt+k",
    "command": "workbench.action.quickOpenSelectPrevious",
    "when": "!editorFocus"
  },
  // Cursor movement with vim style shortcuts
  {
    "key": "alt+k",
    "command": "cursorUp",
    "when": "textInputFocus && !suggestWidgetVisible"
  },
  {
    "key": "alt+j",
    "command": "cursorDown",
    "when": "textInputFocus && !suggestWidgetVisible"
  },
  {
    "key": "alt+h",
    "command": "cursorLeft",
    "when": "textInputFocus && !suggestWidgetVisible"
  },
  {
    "key": "alt+l",
    "command": "cursorRight",
    "when": "textInputFocus && !suggestWidgetVisible"
  }
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM