Vim: Mapping ALt + Key is not working

Created on 17 Apr 2020  路  3Comments  路  Source: VSCodeVim/Vim

As the title, it's my setting below, by the way, the before:["C-k"] is wroking nomrally
in setting.json
"vim.normal..." :{
"before":["A-k"],
"after":["C-i"],
}
Is there something other setting in vscode which i need to handle?

Most helpful comment

As far as I know there is currently no support for 'Alt' keys combinations. For now as a workaround you can change the keybindings directly in VSCode.

If you go to VSCode's 'Keyboard Shortcuts' (you can press Ctrl+Shift+P to open command palette then type 'Preferences: Open Keyboard Shortcuts (JSON)' to open the shortcuts file) and then you can add the following shortcuts:

    {
        "key": "alt+j",
        "command": "editor.action.moveLinesDownAction",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "alt+k",
        "command": "editor.action.moveLinesUpAction",
        "when": "editorTextFocus && !editorReadonly"
    },

This will allow you to also use 'Alt+k' and 'Alt+j' to move lines up and down respectively. And since this is native to VSCode it will work no matter what mode you are in.

All 3 comments

Hi, afaik alt key mappings are not supported as of now:
https://github.com/VSCodeVim/Vim/issues/2713

For your special case, C-i is jump forward, right? If there is an equivalent vscode function, one could create a keybinding to that.

Hi, ALT key is not been mapped. I'm trying to map keys to move lines up and down with and but not working. When changes to and works as expected. Tried on Ubuntu and Windows 10, no success.

"vim.visualModeKeyBindingsNonRecursive": [
    {
      "before": ["<A-j>"],
      "commands": ["editor.action.moveLinesDownAction"]
    },
    {
      "before": ["<A-k>"],
      "commands": ["editor.action.moveLinesUpAction"]
    }
]

I don't get why its happening because in previous releases alt key is supported (https://github.com/VSCodeVim/Vim/issues/2713#issuecomment-616074103). Maybe a bug is still occurring?

As far as I know there is currently no support for 'Alt' keys combinations. For now as a workaround you can change the keybindings directly in VSCode.

If you go to VSCode's 'Keyboard Shortcuts' (you can press Ctrl+Shift+P to open command palette then type 'Preferences: Open Keyboard Shortcuts (JSON)' to open the shortcuts file) and then you can add the following shortcuts:

    {
        "key": "alt+j",
        "command": "editor.action.moveLinesDownAction",
        "when": "editorTextFocus && !editorReadonly"
    },
    {
        "key": "alt+k",
        "command": "editor.action.moveLinesUpAction",
        "when": "editorTextFocus && !editorReadonly"
    },

This will allow you to also use 'Alt+k' and 'Alt+j' to move lines up and down respectively. And since this is native to VSCode it will work no matter what mode you are in.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rajinder-yadav picture rajinder-yadav  路  3Comments

waltiam picture waltiam  路  3Comments

triztian picture triztian  路  3Comments

stefanoio picture stefanoio  路  3Comments

spinningarrow picture spinningarrow  路  3Comments