Vim: custom <Esc> key binding "jj" stoped working when entering insert mode from "cw"

Created on 3 Oct 2018  路  7Comments  路  Source: VSCodeVim/Vim

Describe the bug
Leaving insert mode with a custom key binding does not work if you entered insert mode from a "cw" command.

To Reproduce
Steps to reproduce the behavior:

1.
map "jj" to <Esc> with

 "vim.insertModeKeyBindings": [
        {
            "before": ["j", "j"],
            "after": ["<Esc>"]
        }
    ]
  1. hit "i" to enter insert mode and write some text. Press "jj" to confirm it leaves insert mode.
  2. go to the start of the text/word and hit "cw" to change the word.
  3. hit "jj"
  4. just keeps rendering the letter "j" and does not leave insert mode as it should.

Expected behavior
When entering insert mode with "cw" typing "jj", if mapped to <Esc>, should indeed exit insert mode considering it works fine when hitting "i" then hitting 'jj".

Screenshots
vscode

Environment (please complete the following information):

  • Extension Name: vim
  • Extension Version: 0.16.6
  • OS Version: Darwin x64 17.7.0
  • VSCode version: 1.27.2

Additional context

statuduplicate

Most helpful comment

Bug fix PR is up. Remappings should work in this case if an operator combination results in leaving normal mode. I added a test as well to make sure we don't have future regressions.

All 7 comments

Thanks for the report! I was able to reproduce, and I will take a look.

This is a regression from #3081, which enabled black hole remappings by preventing use of remappings after an operator is pressed. That logic seems like it would work, except in this case the whole "ciwjj" is considered one key combination (which makes sense, as Vim would count it as one combination on e.g. undo), and therefore it sees an operator (the c key) is in play and thinks it shouldn't allow remappings.

I believe what is needed is to ensure post-operator keys don't remap only in Normal mode. I will create some unit tests for the scenarios you mention, and put up a fix PR.

Bug fix PR is up. Remappings should work in this case if an operator combination results in leaving normal mode. I added a test as well to make sure we don't have future regressions.

As a temporary workaround in the meantime, you can downgrade this extension to the previous version:
1) Download: https://github.com/VSCodeVim/Vim/releases/download/v0.16.5/vim-0.16.5.vsix
2) From the VSCode Command Palette (cmd+shift+P), select Extensions: Install from VSIX...
3) Choose the old vsix file, and override the current version with the old one
4) ciwHooray!jj

@sarink When a new version is available how can I update from this custom version?

Also curious about how to update. I'm noticing that this custom remap breaks in a few different instances, not just cw.

An update is planned for tonight I heard. I'm not sure about if you install a custom version, you might have to uninstall it and reinstall from searching in the store after the update is released.

To re-update, simply uninstall and reinstall, it's no big deal.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stefanoio picture stefanoio  路  3Comments

ACollectionOfAtoms picture ACollectionOfAtoms  路  3Comments

lucastheisen picture lucastheisen  路  3Comments

waltiam picture waltiam  路  3Comments

rajinder-yadav picture rajinder-yadav  路  3Comments