Custom Keybindings

I quite like how Zed handles keybindings

For example, here are my mappings

[
  {
    "context": "Editor && vim_mode == insert && !menu",
    "bindings": {
      "j j": "vim::NormalBefore"
    }
  },
  {
    "context": "Editor && vim_mode == normal && !menu",
    "bindings": {
      "space w": "workspace::Save",
      "space s t": "workspace::NewSearch",
      "space f": "file_finder::Toggle"
    }
  }
]

I do think this should happen after the settings refactor.

There’s some initial work towards refactoring here:

And I also think something like KDL would be better suited, so perhaps just a revamped config file would make sense

We’d need

  1. Sort out settings, they’re messy
  2. Abstract away inputs. The UI should handle actions, not actual key combos. Then all of our mappings can just be key → action, rather than key → implementation
  3. Figure out a nice format that can express keybindings in a flexible enough way
2 Likes