Vim VS Code Extension: How to remap "i" in normal mode to Escape key? - visual-studio-code

So I want to remap "i" to escape key since i find it easier to remember. But when I do this to settings.json of the VS Code:
"vim.normalModeKeyBindings": [
{
"before": [
"i"
],
"after": [
"<Esc>"
]
}
]
The "i" key is disabled and nothing happens. Just the "i" key in insert mode being disabled. Help, I'm new to vim.

In Vim, the i keybinding is used to go into insert mode from normal mode. The esc key is usually used to go into normal mode. Setting i as esc is definitely an anti-pattern. Usually people set CapsLock as esc key since it's nearer to the home row in keyboard and you don't have to reach as far as esc key, and since it's annoying sometimes.
I have also seen some people using jj over esc.
Nevertheless, to answer your question, just open Preferences: Open Keyboard Shortcut from command palette(Ctrl+Shift+p) and search for vim_escape. Then double click on it and enter the key i and then press enter again. That should get you the desired result.
Again, suggesting you to not go ahead with this remapping.

open keyboards shortcuts in vscode (ctrl + k, ctrl +s) then search for vim_insert you can change the "i" key to anything that you want.

Came from running VSCode vim keys in windows. microsoft/Powertoys can remap keys like escape to capslock as in this tutorial if one was content doing global keyboard mappings like on ubuntu.

Related

Is there a way to add a keybinding shortcut that doesn't conflict with the existing ones (Visual Studio Code)

I'm trying to add a keyword shortcut that will close all the editors on the right side from the selected one. Somehow this is not by default in vscode on mac (or maybe just to me), I remember using it on window.
Anyway I created the shortcut based on cmd+w closing the selected editor. I thought using cmd + ->(right arrow) w. And it works perfectly for closing the editors. But it conflicts with the existing one cmd + -> that is used to go to the end of the line. How to make both to work.
I don't want to use other keybindings such as a unique one because these keys combination make sense to me. Well I tried also something like cmd+r w. Same problem, there is already a shortcut for cmd+r. And can't use it because it waits for the next key to be added.
There is already a command that does what you want (that is unound by default). Put this into your keybindings.json:
{
"key": "alt+right w", // choose your keybinding
"command": "workbench.action.closeEditorsToTheRight"
}
That's Alt+rightArrow and then a w (or whatever the Alt is on a mac. My guess is that Alt+rightArrow is not bound to anything on a mac.
Since there is no when clause to distinguish this command from Cmd+rightArrow or Cmd+R, using a unique keybinding like alt+right w (option+right w) is as close as you are going to get.

VSCode - keybinding cannot bind my shortcut

I set Ctrl+Alt+l to format document in VSCode. It used to work but after a while of being inactive I tried to use it again with no success.
When I press the shortcut it produces a Polish letter "ł" (for which the shortcut in Windows10 is right Alt+l).
The shortcut is established in VSCode though. It says Format Document - Keybinding Ctrl + Alt + L. The shortcut isn't doubling.
Formatting document works if I use it from straight from VSCode.
So, your system's keybinding is probably having a preference over that keybind. Can't you remove that keyboard shortcut from your system, or change your keyboard language if you don't use those polish keys?

Vim Keymap with Multiplicity on VS Code

I have remapped some vim keys in VS Code (using Vim emulation) but I can't manage to use them with multiplicity.
What this means is that when you normally press 3dd it deletes 3 lines. I have keymapped the normal version of the function dd like this
{
"before": ["<Leader>","c","l"],
"after": ["d","d"]
}
but it doesn't work if I press 3-leader-c-l.
How do you keymap keys with that functionality?

How to remap all ctrl+k chords at once in VSCode

Is it possible to remap all chords at once that use ctrl+k as the first keypress action?
I use ctrl+k to delete rest of the line. Since it conflicts with the most common chord used in vscode, remapping shortcut by shortcut would be inconvenient.
I found a workflow that you could use:
Click Gear icon/KeyBoard Shortcuts
Click "...open and edit keybindings.json"
In the left panel with cursor focus - readonly - search for ({.*ctrl\+k.*},)|({.*ctrl\+k.*\n\s+.*},)
with the regex option chosen. You should get about 57 matches found.
Ctrl-Shift-L will select all matches.
Ctrl-C to copy all those.
Shift cursor focus to right panel - keybindings.json - and paste Ctrl-P clipboard to end of file.
Now you can find/replace those ctrl+k's to whatever you want.
I have no doubt that that regex in step 3 could be simplified, the problem being sometimes there is a newline and "when" modifiers on a second line of the command. Perhaps someone else could help there.

Jump to Closing tag in VS Code?

I can't seem to find a way to select the beginning of a bracket and jump to the end of it through some key combination or something in VS Code. For example, in atom, this is done with Ctrl + m.
I know there is a way to jump to the beginning and end of a bracket or curlybraces with Cmd + Shift + \ but that does not work for tags. Any ideas?
It is possible to do, but either using Ctrl + Shift + P -> "Emmet: Go to Matching Pair" or by manually setting a shortcut for it (Ctrl + K Ctrl + S).
Unfortunately there is currently no support for it out of the box.
You can use Cmd + % to jump tags in VSCode if you add the following to your keybindings.json.
{
"key":"cmd+shift+5",
"command": "editor.emmet.action.matchTag"
}
Go to: File > Preferences > Keyboard Shortcuts and click the underlined link to edit keybindings.json.
For those using VIM keys: you are already used to pressing % to jump to matching parens and tags. So, hopefully, Cmd + % will be close enough to your existing muscle memory to make this transition painless.
For those who are using Vim plugin and Mac, Leader+% is working well for me.
You can setup in your Vim json file setting.json by adding:
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "%"],
"commands": [
{
"command": "editor.emmet.action.matchTag"
}
]
}
]
PS. I mentioned Mac user because cmd+shift+5 is for capturing the screen in Mac.
You can jump to the matching bracket with Ctrl+Shift+\
For more reference, you can refer: Visual Studio Code Navigation
I think you are asking about Breadcrumb Keyboard Navigation
In this case you can simply press Ctrl+Shift+. to go to elements before or after the current element.
There is no support for this out of the box. Though if you are willing to use extensions, there is: https://marketplace.visualstudio.com/items?itemName=vincaslt.highlight-matching-tag which among other things, gives you ability to use command: Jump to matching tag which you can bind to a key.