Please _thumbs-up_ 馃憤 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.
Attempted to map the caps lock key to the escape key, via the below in keybindings.json
{"key": "capslock", "command": "extension.vim_escape"}
Note: I also tried via the below, using "capslock" and "<CapsLock> isn't recognized notation.
{
"vim.insertModeKeyBindings": [
{
"before": ["capslock"],
"after": ["<Esc>"]
}
]
}
This should allow me to exit insert mode via the close-by caplock key.
It does kinda work via the first form above, however if also toggles caps lock on/off, which makes it impossible to use (as every key press is then a capital after exiting insert mode). Preferably the "vim.insertModeKeyBindings" would work, and recognize the capslock key and intercept it - preventing it from toggling caps-lock.
Interestingly, I don't see the capslock key being bubbled up into our extension. We'll need to ask VS Code to add this to their extension API.
Actually, I just noticed even in Windows this usually requires some system changes via the registry or a utility to work correctly - so maybe it wasn't as simple as I hoped :-/ See http://vim.wikia.com/wiki/VimTip75
Yeah, Vim does not support caps lock mapping. People generally map it with some sort of broader keymapping program.
for Mac OS X I personally use Seil + Karabiner or Karabiner-Elements (if you are on Sierra).
you could take a look at this awesome post: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/
On Linux Gnome desktops, Tweak Tool, under the "Typing" menu, will let you set your cap lock behavior. Setting it to "Make Caps Lock an additional ESC" works well for me.
Doing
setxkbmap -option caps:swapescape
on Linux swaps the escape and caps lock Xorg wide. But since code 1.11 this extension does not recognise this. To get out of insert mode, I have to press the original esc key, which at the same time toggles CAPS. This is really annoying.
Might be a problem with code itself: Microsoft/vscode/issues/23991
Would probably be good to test with other parts of VSCode that use an ESC key to trigger something. We don't really have anything to do with capslock binding, unfortunately!
It's definitely an issue with VS Code itself. Going back to 1.10 brings back the expected behavior, so it's something in the 1.11 update that's broken it.
@areyoureddy In that case, definitely go open up an issue on their repository then. :)
Microsoft/vscode#23991 Already done :+1:
Issue resolved?
keybindings.json
// Place your key bindings in this file to overwrite the defaults
[ {"key": "capslock", "command": "extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl" }
]
Ubuntu 16.04, VS Code 12.2.2
Doesn't work correctly in window 10.
@Fr4nks This works for me just well under Linux.
@Fr4nks solution worked for me to, thank.
@Fr4nks Thanks!
@Fr4nks First it didn't work for me. But after adding "keyboard.dispatch": "keyCode" in the settings file which was suggested as a workaround here, it's now working correctly.
VS Code version: 1.14.1
@Fr4nks thank you!
@Fr4nks Thanks!
I put this in keybinds.json
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "capslock",
"command": "extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl"
}
]
And toggle this in User Settings
"keyboard.dispatch": "keyCode"
Now I can use caps lock as esc in vim insert mode. But
I have to press caps lock again because it capitalize my letters. 馃槗
@Ding-Fan I suggest using some kind of external caps lock to escape rebinding program. I use caps2esc on Arch Linux.
@Chillee I'm using Karabiner-Elements on macOS now, it's amazing. 馃槂
In case it is of use to anyone, on macOS, I had set capslock to be escape, and it was previously working fine, but after using setting sync to import my settings, I stopped being able to get out of insert mode. It turned out that "vim.enableNeovim": true, was the culprit. I set it to false and everything was fine again.
On mac you can also map caps lock natively: https://stackoverflow.com/questions/127591/using-caps-lock-as-esc-in-mac-os-x/40254864#40254864
On Fedora 29 I just needed to change an option in the Settings (File > Preference > Settings).
Keyboard: Dispatch "keyCode"
@Ding-Fan I suggest using some kind of external caps lock to escape rebinding program. I use caps2esc on Arch Linux.
I'm also using caps2esc and it works fine everywhere but in code. Sometimes it works for a couple of minutes, then pressing capslock does not trigger esc anymore.
EDIT: Adding "keyboard.dispatch": "keyCode" to user configs solves the problem. Thank you, @Fr4nks.
Issue resolved?
keybindings.json
// Place your key bindings in this file to overwrite the defaults
[ {"key": "capslock", "command": "extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl" }
]Ubuntu 16.04, VS Code 12.2.2
Doesn't work correctly in window 10.
works on ubuntu
If anyone's wondering, as I had a problem finding keybindings.json through the vscode UI, it's in ~/.config/Code/User/.
And you can find some docs about it in VSCode's Docs
@seanwarman In vscode you can get to the keyboard shortcuts using:
Ctrl + Shift + P and type Open Keyboard Shortcuts (json)
For Windows users, after realizing how difficult it would be to implement with VS code settings, I found just changing the registry to be much easier and less finnicky. This same guide shows how to do it with various tools like AHK too. https://vim.fandom.com/wiki/Map_caps_lock_to_escape_in_Windows
For Windows 10, I created a file.reg with the following text:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,3a,00,46,00,01,00,3a,00,00,00,00,00
Double-clicked that file from explorer, then restarted my computer and it works like a charm. Of course, if you use the CAPS lock outside VS code, this solution isn't for you.
Win10 I had a similar issue as others by having to 2nd press the cap lock to turn the cap lock back off. So I decided to just map CapLock + CapLock. So a double caps Esc and turns the caps back off.
Most helpful comment
Issue resolved?
keybindings.json
// Place your key bindings in this file to overwrite the defaults
[ {"key": "capslock", "command": "extension.vim_escape",
"when": "editorTextFocus && vim.active && !inDebugRepl" }
]
Ubuntu 16.04, VS Code 12.2.2
Doesn't work correctly in window 10.