zed icon indicating copy to clipboard operation
zed copied to clipboard

[vim] I set it to do escape when I press jk, but it doesn't work when I press jk during auto completion.

Open YoungHaKim7 opened this issue 1 year ago • 2 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

I set it to do escape when I press jk, but it doesn't work when I press jk during auto completion.

{
  "context": "Editor && vim_mode == insert && !menu",
  "bindings": {
    // put key-bindings here if you want them to work in insert mode
    // ~~~~~~ Insert Mode
    "j k": ["vim::SwitchMode", "Normal"]
  }
},

Environment

Zed: v0.124.8 (Zed) OS: macOS 14.2.1 23C71 arm64 Memory: 16 GiB Architecture: aarch64(M1 macPro)

If applicable, add mockups / screenshots to help explain present your vision of the feature

  • My NeoVim

https://github.com/zed-industries/zed/assets/67513038/b7db96e0-5b83-45f1-aee1-30851bfad0dc

  • Zed (Not Working)

https://github.com/zed-industries/zed/assets/67513038/579e9fc4-a35c-4141-9ad4-6e9e75850e74

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

No response

YoungHaKim7 avatar Mar 02 '24 22:03 YoungHaKim7

"bindings": { "j k": "vim::NormalBefore" // remap jk in insert mode to escape.} you must replace your code with this

eminoz avatar Mar 04 '24 15:03 eminoz

-> Solution https://github.com/zed-industries/zed/discussions/6661

When I press jk, there is something I have to type with a delay of 1,000ms(1sec). When I type, I press faster than that time, so I have to type it like the code above to input jk immediately.

-> Delay Issues https://github.com/zed-industries/zed/pull/4189

YoungHaKim7 avatar Mar 04 '24 16:03 YoungHaKim7

In your context you have " "context": "Editor && vim_mode == insert && !menu". This means that the bindings won't apply when the menu is open.

I think you need: "context": "Editor && vim_mode == insert", instead.

Getting the contexts right in the keybindings file is a known problem right now, so help clarifying the documentation is much appreciated.

ConradIrwin avatar Mar 07 '24 04:03 ConradIrwin

It works fine, thank you.

  {
    "context": "Editor && vim_mode == insert && !menu",
    "bindings": {
      // put key-bindings here if you want them to work in insert mode
      // ~~~~~~ Insert Mode
      "j k": ["vim::SwitchMode", "Normal"]
    }
  },
  {
    "context": "Editor && vim_mode == insert && menu",
    "bindings": {
      // put key-bindings here if you want them to work in insert mode
      // ~~~~~~ Insert Mode
      "j k": ["vim::SwitchMode", "Normal"]
    }
  },

YoungHaKim7 avatar Mar 07 '24 10:03 YoungHaKim7

[
  {
    "context": "Editor && VimControl && !VimWaiting && !menu",
    "bindings": {
      // put key-bindings here if you want them to work in normal & visual mode
    }
  },
  {
    "context": "Editor && vim_mode == normal && !VimWaiting && !menu",
    "bindings": {
      // put key-bindings here if you want them to work only in normal mode
      // ~~~~~~~ Normal Mode
      // Doc hover
      "K": "editor::Hover",
      // buffer :bn :bp
      "L": "pane::ActivateNextItem",
      "H": "pane::ActivatePrevItem",
      // quick fix
      "space g a": "editor::ToggleCodeActions",
      "] d": "editor::GoToDiagnostic",
      "[ d": "editor::GoToPrevDiagnostic",
      "g m": "editor::ExpandMacroRecursively",
      // LSP rename    "ga" multi cursor
      "space r": "editor::Rename",
      // symbol search   "gs"
      "space o": "project_symbols::Toggle",
      // NERDTree
      "space e": "project_panel::ToggleFocus",
      "space x": "workspace::CloseAllDocks",
      // Terminal Pannel(shell)
      "space s h": "terminal_panel::ToggleFocus",
      // trouble toggle
      "space t": "diagnostics::Deploy"
    }
  },
  {
    "context": "Editor && vim_mode == visual && !VimWaiting && !menu",
    "bindings": {
      // visual, visual line & visual block modes
      // ~~~~~~ Visual Mode
      "K": "editor::MoveLineUp",
      "J": "editor::MoveLineDown",
      "space g c": "editor::ToggleComments"
    }
  },
  {
    "context": "Editor && vim_mode == insert && !menu",
    "bindings": {
      // put key-bindings here if you want them to work in insert mode
      // ~~~~~~ Insert Mode
      "j k": ["vim::SwitchMode", "Normal"]
    }
  },
  {
    "context": "Editor && vim_mode == insert && menu",
    "bindings": {
      // put key-bindings here if you want them to work in insert mode
      // ~~~~~~ Insert Mode
      "j k": ["vim::SwitchMode", "Normal"]
    }
  },
  {
    "context": "ProjectPanel",
    "bindings": {
      "h": "project_panel::CollapseSelectedEntry",
      "l": "project_panel::ExpandSelectedEntry",
      "j": "menu::SelectNext",
      "k": "menu::SelectPrev",
      "o": "menu::Confirm",
      "r": "project_panel::Rename",
      "z c": "project_panel::CollapseSelectedEntry",
      "z o": "project_panel::ExpandSelectedEntry",
      "shift-o": "project_panel::RevealInFinder",
      "x": "project_panel::Cut",
      "c": "project_panel::Copy",
      "p": "project_panel::Paste",
      "d": "project_panel::Delete",
      "a": "project_panel::NewFile",
      "shift-a": "project_panel::NewDirectory",
      "shift-y": "project_panel::CopyRelativePath",
      "g y": "project_panel::CopyPath"
    }
  }
]

YoungHaKim7 avatar Mar 07 '24 10:03 YoungHaKim7