Is it possible to map ‘Ctrl+CapsLock’ to escape key in VSCode Vim?

5,809

I found a solution to map Ctrl+CapsLock to vim_escape key.

  1. Enter “Preferences: Open Keyboard Shortcut” Menu (using Ctrl +Shift+P)

  2. Click a extension.vim_escape item.

  3. Hold the Ctrl + CapsLock key for 3+ seconds. dialog box for extension.vim_escape key

  4. Press Enter key.

display current extension.vim_escape shortkey

Share:
5,809

Related videos on Youtube

Afrontend
Author by

Afrontend

Updated on September 18, 2022

Comments

  • Afrontend
    Afrontend over 1 year

    I’m using a CapsLock key as a Ctrl key and an Esc key using below command

    remapCapsLockToControl() {
        xmodmap -e 'keycode 66 = Control_L'
        xmodmap -e 'clear Lock'
        xmodmap -e 'add Control = Control_L'
        echo "remapCapsLockToControl"
    }
    
    remapControlToEsc() {
        xcape -e "Control_L=Escape"
        echo "remapControlToEsc"
    }
    

    I can use a CapsLock key as an Esc key in Vim (Ubuntu 18) with these settings. But I can’t use a CapsLock key as an Escape key in VSCode vim mode. VSCode displays a message below when pressing a CapsLock key.

    (Ctrl+CapsLock) was pressed. Waiting for second key …

    I can’t input the Ctrl+CapsLock key to extension.vim_escape of “Preferences: Open Keyboard Shortcut”. A key input window is closed when press a CapsLock key.

  • Giacomo1968
    Giacomo1968 almost 5 years
    Excellent self-answered question!
  • phuongnd
    phuongnd about 4 years
    It worked like a charm
  • durka42
    durka42 over 2 years
    I found two notes: 1) You can right click and "Add Keybinding" to keep the original as an option for vim_escape. 2) The keybinding I am trying to add is CapsLock+[ (I have caps lock mapped as control via xmodmap but VS Code seems to see through this somehow...) and holding the key combination down for a while does nothing. However, very quickly pressing CapsLock+[+Enter does the trick!
  • Giacomo1968
    Giacomo1968 over 2 years
    Nothing wrong with linking an answer from another Stack Exchange site, but you should quote pertinent text from the answer here as well so this answer is complete. Otherwise, it’s just a link-only answer.
  • DarkDiamond
    DarkDiamond over 2 years
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review