Keybindings with Alt modifier.
FEATURE REQUEST
I would like to be able to bind key sequences with alt to vim keys, specifically Alt + v to V like so:
{ "before": [ "alt+v" ], "after": [ "V" ], },
Would this be hard to implement ?
We support this already. Have you tried using the alt key when configuring your remapping? https://github.com/VSCodeVim/Vim#key-remapping
Here's what i have tried. This setting seems to have no effect. :
"vim.otherModesKeyBindingsNonRecursive": [
{
"before": ["alt+v"],
"after": ["V"]
}
],
It appears to not capture the alt key at all. When i try to bind any other alt combination like "alt+x", or just "alt" to any other command like so:
"vim.otherModesKeyBindingsNonRecursive": [
{
"before": ["alt+x"],
"after": [],
"commands": [
{
"command": "workbench.action.showCommands",
"args": []
}
]
}
]
It also wouldn't work. Using other modifier keys like "<c-x>" worked.
Here are some options in my configuration that may me worth mentioning:
"window.menuBarVisibility": "hidden",
"window.enableMenuBarMnemonics": false,
Environment
VSCode version: 1.24.0 VSCode commit: 6a6e02cef0f2122ee1469765b704faf5d0e0d859 OS: Windows 10 Pro x64 Extension version: v0.12.0
I have the same issue on Linux (arch). Enabling debugging, I can see that keys using the alt modifier are not captured at all, i.e. does not print any Remapper: debug: trying to find matching remap lines.
Same issue on Linux (ubuntu) Other findings may be related or not. with Debug enabled:
- do not log any ALT key combination
- do not log ctrl+h or ctrl+l (defined on package.json), but works
- log ctrl+pageUp and ctrl+pageDown (defined on package.json), works
Environment
Version: 1.33.0
Commit: 0dd516dd412d42323fc3464531b1c715d51c4c1a
Date: 2019-04-04T15:08:57.775Z
Electron: 3.1.6
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.15.0-47-generic
I was mistaken. We don't bind to alt. See the second bullet point of https://github.com/VSCodeVim/Vim#debugging-remappings.
Is this something that can be implemented?
Bump. Any chance of implementing this? My leader key is usually alt-space, which lets me use it in any mode, including insert mode, and even outside the editor.
+1
A common use case is A-j/A-k for moving lines. It's annoying to have to use the arrow keys for this in VSCode, which has the same mapped to A-down/A-up. I poked around in the code for a bit trying to figure out where captured keys are defined, but I've spent too long at this point to want to do it on my own. Please reopen

A common use case is A-j/A-k for moving lines. It's annoying to have to use the arrow keys for this in VSCode, which has the same mapped to A-down/A-up. I poked around in the code for a bit trying to figure out where captured keys are defined, but I've spent too long at this point to want to do it on my own. Please reopen
I have the exact need. <A-k>/<A-j> for moving lines up/down. Will adding the keybinding in package.json enable this?
The problem with binding to alt+... key combinations is that it would make those combinations stop working for their normal behavior and there is a lot of alt+... that are either used by default vscode commands or by other extensions.
If we bound to those key combos we would enter in conflict with the commands of those other extensions. This would happen even if the user wasn't using those key combos for any remap.
It might be possible to only bind to those key combos when a remap that uses it is configured. But it would still conflict if there was the same key combo being used by another extension.
For now as a workaround for moving lines with <A-j> and <A-k> you can add this to your 'keybindings.json' file:
{
"key": "alt+j",
"command": "editor.action.moveLinesDownAction",
"when": "editorTextFocus && !editorReadonly && vim.active"
},
{
"key": "alt+k",
"command": "editor.action.moveLinesUpAction",
"when": "editorTextFocus && !editorReadonly && vim.active"
},
@berknam hmm. makes sense. I have added the above custom keyboard shortcuts and they gel nicely. thanks.
We should probably provide bindings like these but set their default values in handleKeys to false.
We should probably provide bindings like these but set their default values in
handleKeysto false.
That's a great option! Should be simple enough to do.
I came here one year ago, and yet it's still the reason rejecting me from VSCode.... :(
One year is relative small amount of time for Microsoft ) In 2010 I was newbie in programming, and has an order for .NET, I made it, but it is was a pain, and I was switched total to frontend development , it was like a gulp of fresh air, coding flow goes easily, time was going and ..tada.. Microsoft gets GitHub, had buried Atom, and born VSCode... Welcome back devil says
This feature is so important. Being able to remap a-l to right or a-h to left prevent to have to press enter just for movin a stupid char on the side during a typo or some scope movements.
Hello, friends. If anyone would share their experience about working with <F12> and Alt-left to call "Go Back"? What about Alt+] in Co-Pilot option selection?
Yeah this is a glaring hole in the space of useful mod keys. I would happily toss out all the other conflicting extensions (insofar as i understand @berknam ) if that would give me the Alt key for binding. Is there chance you can add "hard-override"?
i actually have the inverse, after re-installing vscode from scratch vim intercepts alt+shift and i dont see any way to disable this. ie alt+shift+up\down
Well, I come here again, and finally find out that 5 years later, eventually it had been fixed : Remapping more complex key combinations!
The problem with binding to
alt+...key combinations is that it would make those combinations stop working for their normal behavior and there is a lot ofalt+...that are either used by default vscode commands or by other extensions.If we bound to those key combos we would enter in conflict with the commands of those other extensions. This would happen even if the user wasn't using those key combos for any remap.
It might be possible to only bind to those key combos when a remap that uses it is configured. But it would still conflict if there was the same key combo being used by another extension.
For now as a workaround for moving lines with
<A-j>and<A-k>you can add this to your 'keybindings.json' file:{ "key": "alt+j", "command": "editor.action.moveLinesDownAction", "when": "editorTextFocus && !editorReadonly && vim.active" }, { "key": "alt+k", "command": "editor.action.moveLinesUpAction", "when": "editorTextFocus && !editorReadonly && vim.active" },
This also works on mac at least
{
"before": ["∆"],
"commands": ["editor.action.moveLinesDownAction"]
},
{
"before": ["˚"],
"commands": ["editor.action.moveLinesUpAction"]
},