zsh-vi-mode
zsh-vi-mode copied to clipboard
Move through wrapped lines using `gj` and `gk`
Basic examination
- [x] I have read through the README page
- [x] I have the latest version of zsh-vi-mode
- [x] I have tested with another terminal program (UXTerm, kitty)
Problem description
Can't get gj
and gk
to work
Reproduction steps
- Having a long one line command wrapped into next line
- Try to move up using
gk
in normal mode - Nothing happens
Expected behavior
Move up and down through the wrapping lines (like what Vim does)
Just to say that I'm rooting for this feature too.
Same here - any idea on how this might be done @jeffreytse? We might be able to put in a PR for this feature
I've opened a PR to add this in @jeffreytse 😃 Check out #177
Looks like my PR has been closed. Owner might have a different approach to doing this
Looks like @kangadrewie's fix didn't accept a count. So neither 3gj nor 2gk would work. There is also a change that looks like a typo in the zvm_escape_non_printed_characters() function.
Hi @kangadrewie
Thanks for your contribution, I didn't close your PR, and as @gonubana said, there is a typo in the zvm_escape_non_printed_characters()
function. : )
Thanks & Regards
I started looking at this for my own plugin, and it gets super complex if you want to do it totally correctly. You could probably get away with this (accepts count):
zvm_up_visual_line(){
zle -f vichange
((CURSOR += NUMERIC * COLUMNS))
}
zvm_down_visual_line(){
zle -f vichange
((CURSOR -= NUMERIC * COLUMNS))
}
But this only works if:
- moving with a wrapped line, not between lines
- that wrapped line doesn't have tab characters
This might be good enough to appease most people; while I use multi-line editing a fair bit (I have a widget which loads a function definition into the buffer, which always is multi-line and tabbed) I'm not sure how much others do. There's an extra complexity which happen when moving to or from the first line, where the prompt isn't accounted for in the visual count.
I'm still writing my more complete implementation, but I think I'lll probably resort to using terminfo[u7]
to ask the terminal where the cursor is.