question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remapping ESC in insert mode with CR or Space does work via settings

See original GitHub issue

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

What happened: Remapping to ESC does not work at all. This includes the solution posted in the README and will all other extensions disabled. I have no fucking clue what’s going on.

I’ve been going off of #1908 and #2411 as some general guidelines to trying to solve the issue. Firstly, as previously mentioned, I tried the solution presented in the README:

"vim.insertModeKeyBindings": [
        {
            "before": ["j", "j"],
            "after": ["<Esc>"]
        }
    ]

When I’m in insert mode and press <kbd>j</kbd><kbd>j</kbd> it simply types out “jj”. Honestly, that’s not that surprising to me. I have no idea why you’d want this anyways (I’m probably using it wrong honestly).

I’ve traded out the "before" sequence for ["j","j"], ["<S-Space>"], and ["<S-CR>"],

I’ve traded out the "after" for the "commands" equivalent ("extension.vim_escape").

I’ve tried out "vim.insertModeKeyBindings" for "vim.insertModeKeyBindingsNonRecursive"

None of these work. Again, the only extension enabled is Vim. And it doesn’t do anything

What did you expect to happen: I expected to type <kbd>j</kbd><kbd>j</kbd> or whatever key combination I’ve chosen to escape insert mode while I’m in insert mode.

How to reproduce it (as minimally and precisely as possible):

  1. Put the before mentioned solution from the README into setting.json
  2. Go to a document (python document in my case)
  3. Press <kbd>i</kbd> to go to insert mode or <kbd>A</kbd> to go append a line (still brings you to insert mode)
  4. Type some giberish
  5. Press <kbd>j</kbd><kbd>j</kbd> on my keyboard quickly
  6. I see “jj” typed out on the screen
  7. Try all the combinations, repeat steps 2-6

Environment:

  • Extension (VsCodeVim) version: 0.11.5
  • VSCode version: 1.22.2
  • OS version: Windows 8.1 (unfortunately)

~Note: I’m using code for keys I physically press and “quotes” for what comes up on screen. So I press the j key and the letter “j” comes up on screen.~ TIL <kbd>[keyboard text]</kbd> is a thing

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jrwrighcommented, Apr 30, 2018

A way I just found around it is to do a keyboard mapping of <kbd>Shift</kbd>+<kbd>Enter</kbd> in normal VS Code keyboard maps:

    {
        "key": "shift+Enter",
        "command": "extension.vim_escape",
        "when": "editorTextFocus"
    }

Probably not ideal, but it doesn’t appear to interfere with anything.

0reactions
jpooncommented, Jun 19, 2018

Mis-read this original issue. The remapping example works for me…

"vim.insertModeKeyBindings": [
        {
            "before": ["j", "j"],
            "after": ["<Esc>"]
        }
    ]

The <Shift> are a little weird. We support remapping of shift + character which in simplified English terms means, the capital form of that character (ie. you can remap “A”, “B”, etc). This extension does not bind to a <Shift>+ Carriage Return/Alt/Tab – we do support shift+backspace (https://github.com/VSCodeVim/Vim/blob/master/package.json#L290) though. What this means is if you press these keycombos, vscode doesn’t pass it along to the extension and therefore we know nothing about it.

Closing this as a dupe of https://github.com/VSCodeVim/Vim/issues/1908

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mapping using <Esc> writes "<Esc>" in insert mode rather ...
It had been working fine, ie it returned me to normal mode. But now it inserts the string "< Esc>" (I use the...
Read more >
Avoid the escape key | Vim Tips Wiki - Fandom
Improving the Esc key​​ The above trick means that the cursor will not move if you press i to enter insert mode, then...
Read more >
Remapping a key to <Esc> Doesn't Work in Command Mode
*3 Go from Command-line mode to Normal mode by: - Hitting <CR> or <NL>, ... noremap <a-space> <esc> inoremap <a-space> <esc> cnoremap ...
Read more >
A improved mapping to leave insert mode than jk or kj or jj : r/vim
So it works like esc when pressed alone and like ctrl when pressed with another key. Done through configuring a programmable keyboard, or...
Read more >
The Only Vim Insert-Mode Cheatsheet You Ever Needed
Another common technique is to remap your <caps lock> key to behave like <esc> . Repeating Insert Mode. You can give a count...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found