[vim] default keymap supplement
Check for existing issues
- [X] Completed
Describe the feature
{
"context": "Editor && VimControl && !VimWaiting && !menu",
"bindings": {
// put key-bindings here if you want them to work in normal & visual mode
"ctrl-w z": "workspace::ToggleZoom",
"ctrl-w t": "terminal_panel::ToggleFocus",
"space g b": "editor::ToggleGitBlame",
"space f f": "file_finder::Toggle",
"space f p": "pane::TogglePreviewTab",
"space f o": "projects::OpenRecent",
"space w": "workspace::Save",
"g ]": "editor::GoToDiagnostic",
"g [": "editor::GoToPrevDiagnostic",
"] x": "editor::SelectSmallerSyntaxNode",
"[ x": "editor::SelectLargerSyntaxNode
},
{
"context": "Editor && vim_mode == normal && !VimWaiting && !menu",
"bindings": {
// put key-bindings here if you want them to work only in normal mode
"g c c": "editor::ToggleComments"
}
},
{
"context": "Editor && vim_mode == visual && !VimWaiting && !menu",
"bindings": {
// visual, visual line & visual block modes
"g c": "editor::ToggleComments"
}
}
If applicable, add mockups / screenshots to help present your vision of the feature
No response
- Fully agreee on
editor::ToggleComments. - Fully agree on
g ]andg [ - I think the
ctrl-wones make sense. ] xand[xwe already have: https://github.com/zed-industries/zed/blob/6f59515dd1f2823d58c34942df82e8e8d21035cd/assets/keymaps/vim.json#L370-L371
The space ones I'm not so sure about, since space as a leader is a bit of a custom thing and I don't think we should introduce space as a default-leader thing (I personally use ,)
@mrnugget
ToggleComments also missing gC functions such as gCi}
current [ x and ] x only in normal ,Unable to expand selection
about the Leader key
First PR here: https://github.com/zed-industries/zed/pull/10461
For the other bindings (ctrl-w ... and space), I'm curious what @ConradIrwin and @baldwindavid think
@mrnugget
- I already had
g candg c cso those are a welcome addition. - Yeah, I don't think we should add
spacekeybindings. I usespaceas my leader key for my own bindings, but think we need to have some sort of leader support before defaulting anything with a leader key. Would be nice if we could configure a leader key in settings and then was available in the keymap as something like$ZED_LEADER. Similarly, would like to be able to access$ZED_FILE,$ZED_ROW, etc in keymaps, like we can in tasks. - I've never, ever used
ctrl-w *keybindings in vim so don't have much of an opinion.
Regarding the unimpaired style ] x and [ x, I learned a really cool trick from #9244 - Not really suggesting as a default, but I've been using it a lot.
{
"context": "Editor && vim_mode == visual && !VimWaiting && !menu",
"bindings": {
"v": "editor::SelectLargerSyntaxNode",
"V": "editor::SelectSmallerSyntaxNode"
}
},
Agreed with not having default bindings with a space so everyone has somewhere they can stash their own things.
For panels we've started the convention of :X opening them, so we could add :Blame for git blame (and ensure that :B selects that) and :Projects for recent projects? (similarly :P). Will work fine until we get up to 26 panes and panels (assuming we name them carefully :D).
I think ctrl-w t is not the right "builtin" shortcut for that (use :T or :te, or ctrl-w j once it's open). ctrl-w t is a vim shortcut (though probably not a zed compatible one)
ctrl-w z could work for zoom. I'm not sure we'll ever build vim-style preview panes, so it's probably ok to reuse. I'd also be open to another key, but ctrl-w is pretty full already, so maybe that's the best option.
@ConradIrwin
Though you cannot operate on arbitrary objects yet, but it is possible to implement gco and gcO in a simple way.
{
"context": "Editor && vim_mode == normal && !VimWaiting",
"bindings": {
"g c o": ["workspace::SendKeystrokes", "o escape g c c shift-a"],
"g c shift-o": [
"workspace::SendKeystrokes",
"shift-o escape g c c shift-a"
]
}
}
I think we can take the same general approach for gc as we just did for > where we have a vim wrapper that sets up the selection, calls the editor command, and restores the selection where we want it.
We'll also need to build the gc object to make it work really well though.
Binding ctrl-w ... will slow down bare ctrl-w like in #14540, right ?
Binding
ctrl-w ...will slow down barectrl-wlike in #14540, right ?
As far as I know if you configure <c-w> and <c-w> x it slows down <c-w>, usually a 1 second delay to determine what keystrokes you end up with, it's usually a good idea to just configure <c-w> to be null and look for <c-w> x to make the new binding
For example, the default keymap