zsh-vi-mode
zsh-vi-mode copied to clipboard
Cursor should move to the end of line when using up/down arrows to look at previous commands
Hi @oars
In fact, the cursor will be move to the end of line when using up/down arrows to look at previous commands. But this is weird your side didn't reach this result. Could you provide me further instructions?
Thanks and regards
Thanks, for some reason in my case the cursor is at the start of the previous commands, not at the end.
I have the same problem, up arrow correctly pastes in previous command, but cursor stays at the beginning of the line. ctrl-p works correctly.
Hi @1m0d
👍 Thanks for the reporting, I'll try to figure out this issue. Any progress I will update here. Also welcome to star this project for further updates in the future.
Thanks and regards
Hi @1m0d
In fact, the Arrow Up/Down
is for partial history search feature, that is the same beginning (based at cursor) of commands in history (#15), if you just want to move to previous command in the history, you should use ctrl-p
or k
(just available in normal mode).
Thanks and regards
By default up arrow is set to up-line-or-history in zsh which you overwrite to history-beginning-search-backward, which has an alternative history-search-backward in which the cursor goes to the end of the line. I do not recommend overwriting default keybinds, but if you do I recommend using history-search-backward so the cursor goes to the end of the line as expected by default.
In case this does not get changed users can just put
bindkey "^[[A" up-line-or-history
bindkey "^[[B" down-line-or-history
or
bindkey "^[[A" history-search-backward
bindkey "^[[B" history-search-forward
to their .zshrc if they want the cursor to go to the end of line.
Edit: Unfortunately even if you set it in .zshrc, the plugin overwrites the bindings.
Hi @1m0d
Thank you for your detailed explanation, I will consider your comments carefully. You should execute your custom keybindings after this plugin initialized (See here).
Thanks and regards
Yes, I missed that part, thank you.
Hi @1m0d @oars
This commit 84b88a4 has revert the bindings of Arrow Up/Down to the default, as that's what most Vi users will expect. And you don't need to do the bindings again in zvm_after_init
function.
Thanks and regards
Hi @oars
Could you have a check with the latest version for this issue? And the issue will be closed if there is no more requests.
Thanks and regards
Edit: Unfortunately even if you set it in .zshrc, the plugin overwrites the bindings.
@1m0d I've managed to fix this behaviour by adding the following at the end of my .zshrc
zvm_after_init_commands+=("bindkey '^[[A' up-line-or-search" "bindkey '^[[B' down-line-or-search")
Edit: Unfortunately even if you set it in .zshrc, the plugin overwrites the bindings.
@1m0d I've managed to fix this behaviour by adding the following at the end of my
.zshrc
zvm_after_init_commands+=("bindkey '^[[A' up-line-or-search" "bindkey '^[[B' down-line-or-search")
@pawurb, In case of something incompatible, I suggest you use the zvm_bindkey
command to do the binding as the document snippet.