Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
YoungHaKim7 opened this issue Mar 2, 2024 · 5 comments
Labels
bug [core label] keymap / key binding Feedback for keyboard shortcuts, key mapping, etc vim

Comments

@YoungHaKim7
Copy link

Check for existing issues

  • 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
Screen.Recording.2024-03-03.at.7.29.13.AM.mov
  • Zed (Not Working)
Screen.Recording.2024-03-03.at.7.30.55.AM.mov

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 YoungHaKim7 added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Mar 2, 2024
@Moshyfawn Moshyfawn added vim keymap / key binding Feedback for keyboard shortcuts, key mapping, etc and removed triage Maintainer needs to classify the issue labels Mar 2, 2024
@eminoz
Copy link

eminoz commented Mar 4, 2024

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

@YoungHaKim7
Copy link
Author

YoungHaKim7 commented Mar 4, 2024

-> Solution
#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
#4189

@JosephTLyons JosephTLyons removed the admin read Pending admin review label Mar 4, 2024
@ConradIrwin
Copy link
Member

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.

@YoungHaKim7
Copy link
Author

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
Copy link
Author

[
  {
    "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"
    }
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] keymap / key binding Feedback for keyboard shortcuts, key mapping, etc vim
Projects
None yet
Development

No branches or pull requests

5 participants