Skip to content

Windows: Vim jj keybinding intercepts j key from Chinese IME #41766

@Evan210

Description

@Evan210

Summary

When the vim in zed is configured to use jj as the keybinding to exit insert mode, the first j keystroke is immediately intercepted by the editor. This prevents the j key from being sent to the active Chinese Input Method Editor (IME), making it impossible to type any Chinese Pinyin word that begins with the letter 'j'.

Description

Steps to trigger the problem:

  1. Add the following configuration to keymap.json to map jj to exit insert mode:
{
    "context": "Editor && vim_mode == insert",
    "bindings": {
        "j j": "vim::NormalBefore"
    }
}
  1. Open any text file in zed and press i to enter vim's insert mode.
  2. Enable a Chinese IME (e.g., Microsoft Pinyin, Sogou).
  3. Try to type any word that starts with 'j', for example, "jintian" (今天 - today).

Expected Behavior: When I type the first j, the keystroke should be sent to the Chinese IME, allowing the IME to show words start with 'j'. The zed should only accept j if the IME is in English mode. This is the standard behavior in other editors and IDEs (like vim/neovim in the terminal and the vim extension in vscode).

Actual Behavior: As soon as the first j is pressed, the keystroke is captured by zed, which is now waiting for the second j. The j key is never sent to the IME. This makes it impossible to type any Chinese word that starts with 'j'.

Using jj (or jk) as the keybinding to exit insert mode is an extremely common and ergonomic configuration for vim users. I am now forced to disable this binding and revert to using the default Ctrl-C or ESC keys, which is very unergonomic and breaks established muscle memory.

From searching existing issues, it appears that several similar issues (21136, 28174, 30393, 31819, 36610, 38616) related to CJK IME key handling have been reported on macOS in the past but have not been fixed. This indicates a broad and long-standing community need for a solution that allows these popular vim keybindings to coexist with IME usage.

Zed Version and System Specs

Zed: v0.208.5 (Zed)
OS: Windows 10.0.26200
Memory: 59.8 GiB
Architecture: x86_64
GPU: AMD Radeon 780M Graphics || AMD Corporation || 23.8.2

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions