Vim: Cannot remap in insert mode

Describe the bug The following setting has no effect:

"vim.insertModeKeyBindingsNonRecursive": [
    {
        "before": ["<C-e>"],
        "after": ["<esc>"]
    }
],

(I don’t actually want it to remap to just <esc>, but I’m starting simple.)

To Reproduce Add the above text to settings.json and save. Enter insert mode and try pressing C-e. The character on the line below the current one is copied in – rather than performing the mapped action of <esc>.

Expected behavior VSCodeVim acts as if Escape was pressed.

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 0.16.12
  • VSCode version: 1.29.1
  • OS: Windows 10.0.15063

Additional context This does not appear to be a duplicate of Unable to remap <C-s> in insert mode. In that issue, the keys that people were trying to remap were not handled by VSCodeVim. In this case, <C-e> is listed in packages.json, and VSCodeVim is doing something with the key (copying the character below the cursor).

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 18 (8 by maintainers)

Most upvoted comments

Same behavior. I tried to remap:

"vim.insertModeKeyBindingsNonRecursive": [{ "before": ["<C-o>", "$"], "after": ["<C-e>"] }]

Apparently there is trouble with remapping ctrl commands in general.

See here for the parent issue. See here for a possible workaround.

I’m hitting this issue also, it’s very annoying but not quite as annoying as #3530 which I strongly suspect has the same cause as this.

Updated to 1.0.5 this morning and this is still not working for me. Or rather, it’s working very inconsistently – sometimes it works. I’ve only gotten it to work directly in the User Settings window and not in any other editor, even after reloading the window, and sometimes it just does nothing or copies the character on the line below (as it did before the change).

Also, if I literally type <C-e> in insert mode as the five characters, the mapping activates. >__<

I tried adding C-e explicitly to vim.handleKeys; doesn’t matter whether I have it in there or not.

Here’s my whole settings.json in case there’s something additional in there that’s interacting:

{
    "window.zoomLevel": 1,
    "editor.acceptSuggestionOnEnter": "off",
    "breadcrumbs.enabled": true,
    "files.trimTrailingWhitespace": true,
    "tfvc.location": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\TF.exe",
    "team.showWelcomeMessage": false,

    "vim.hlsearch": true,
    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": [" "],
            "commands": [
                ":nohlsearch"
            ]
        },
        {
            "before": ["\\"],
            "after": [";"]
        },
        {
            "before": ["|"],
            "after": [","]
        },
        {
            "before": [";"],
            "after": [":"]
        },
    ],
    "vim.insertModeKeyBindingsNonRecursive": [
        {
            "before": ["<C-e>"],
            "after": ["<ESC>"]
        }
    ],

    "vim.handleKeys": {
        "<C-t>": false,
        "<C-j>": false,
        "<C-k>": false,
        "<C-s>": false,
        "<C-e>": true
    },

    "editor.rulers": [80],

    "[powershell]": {
        "editor.rulers": [
            120
        ]
    },

    "[markdown]": {
        "files.trimTrailingWhitespace": false
    },
    "workbench.activityBar.visible": true,
    "gitlens.currentLine.enabled": false,
    "gitlens.hovers.currentLine.over": "line",
    "editor.minimap.enabled": false,
    "workbench.sideBar.location": "right",
    "terminal.integrated.rendererType": "dom",
    "editor.renderControlCharacters": false,
    "editor.renderWhitespace": "all",
    "editor.fontLigatures": true,
    "editor.fontFamily": "'Fira Code Regular', Consolas, 'Courier New', monospace"
}

Oh crap. I’m on mobile. There’s a PR that I just submitted and merged that fixed this issue. You can find the duplicate issue from there.

Edit: dupe of https://github.com/VSCodeVim/Vim/issues/3126

The workaround is good, but it doesn’t help in my case, as I use Ctrl-E to scroll in normal mode without moving the cursor, and not having that is much more annoying than not being able to bind it in insert mode. The keybindings.json is not aware of VSCodeVim’s modes, so I can’t override only in insert mode.

I am not sure that the parent issue @janhesters listed applies to the behavior for C-e in particular… Maybe I’m misunderstanding, but the package.json file appears to be binding to Ctrl-E, and VSCodeVim is able to do things specific to the extension when I press Ctrl-E, so this seems like it may be a different issue.