VSCodeVim / VSCodeVim/Vim

While mapping jk/jj to esc, typing j and a motion hotkey make the j appear after the motion.

Open
#5,279 20 comments 3 reactions 1 assignee View on GitHub

@berknam is already working on this.

Since Dec 9, 2020.

area/remap kind/bug
Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Describe the bug
I have imapped jk to <ESC>, and have some hotkeys like ctrl+a mapped to command cursorHome, ctrl+b to cursorLeft.
Press j and then ctrl+a, the j appears at the start of the line.
That is, the j changes its original location to the location after motion hotkey.
IIRC I don't remember such problem exists before.

To Reproduce

  1. add the following lines to user settings.
    "vim.insertModeKeyBindingsNonRecursive": [
        {
            "before": ["j", "k"],
            "after": ["<esc>"]
        }
    ],

add such hotkeys to keybindings.json

    {
        "key": "ctrl+e",
        "command": "cursorEnd",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Insert'"
    },
    {
        "key": "ctrl+a",
        "command": "cursorHome",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Insert'"
    },
    {
        "key": "ctrl+p",
        "command": "cursorUp",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Insert'"
    },
    {
        "key": "ctrl+n",
        "command": "cursorDown",
        "when": "editorTextFocus && vim.active && !inDebugRepl && vim.mode == 'Insert'"
    },
  1. Say we have a line println($) ($ is where the cursor now at)
    press j and it becomes println(j$) and waiting for a key.
    Then press ctrl+e to move to end of the line.
    The line becomes println()j$
    The j changes its location.
    Other such hotkeys(ctrl+a, ctrl+p, etc.) all behave like this.

Expected behavior
The line becomes println(j)$ ($ is where the cursor now at) but not println()j$.
I remember I used to play around with the variable j without any problem.

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 1.17.1
  • VSCode version: 1.49.2
  • OS: Version 2004 (OS Build 19041.264)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.