Combining vim relative line jumping with up/down display line movement #20863
-
I'm using the following configuration to move display lines with j and k (From: #6753 (comment)): {
"context": "Editor && VimControl && !VimWaiting && !menu",
"bindings": {
"j": ["vim::Down", { "displayLines": true }],
"k": ["vim::Up", { "displayLines": true }]
}
} However, this has the effect of modifying how all line jumps work. e.g., if I type 4k, it'll move 4 display lines up, rather than going to the line that matches the 4th relative line above the current, which is how it works in vim, even if you modify how Is there anyway around this? I'd like to keep sole j and k presses as moving display lines, but line number + directional movement goes to the matching relative line number. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I think you are trying to implement lazyvim keymap. https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua -- better up/down
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true })
map({ "n", "x" }, "<Down>", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true })
map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { desc = "Up", expr = true, silent = true })
map({ "n", "x" }, "<Up>", "v:count == 0 ? 'gk' : 'k'", { desc = "Up", expr = true, silent = true }) According to the current zed implementation, there is no way to implement this, it requires a repeat counting context, this needs to be implemented |
Beta Was this translation helpful? Give feedback.
-
We have a
(Note the order is important VimCount must come after VimControl in the file, because they both match on the same node). |
Beta Was this translation helpful? Give feedback.
We have a
VimCount
in the context. So you could potentially do something similar:(Note the order is important VimCount must come after VimControl in the file, because they both match on the same node).