I recently switched to vi keymap for Zsh. Here are some useful remapping to make it feels smoother:
bindkey -M vicmd '~' vi-swap-case
bindkey -M vicmd 'u' undo
bindkey -M vicmd 'U' redo
bindkey -M vicmd "?" history-incremental-pattern-search-backward
bindkey -M vicmd "/" history-incremental-pattern-search-forward
bindkey -M viins '^?' backward-delete-char # backspace
bindkey -M viins '^[[Z' reverse-menu-complete # shift-tab
bindkey -M viins '^a' beginning-of-line
bindkey -M viins '^e' end-of-line
bindkey -M viins '^h' backward-delete-char
bindkey -M viins '^k' kill-line
bindkey -M viins '^n' down-history
bindkey -M viins '^p' up-history
bindkey -M viins '^u' backward-kill-line
bindkey -M viins '^w' backward-delete-word
bindkey -M viins '^y' yank
autoload -U edit-command-line
zle -N edit-command-line
bindkey '^f' edit-command-line
I don’t use ^r
for backward search since it is managed by Fzf directly.
And in Tmux:
bind -T copy-mode-vi u send-keys -X halfpage-up
bind -T copy-mode-vi d send-keys -X halfpage-down
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi C-l send-keys -X clear-selection
bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel
bind -T copy-mode-vi 'C-v' send-keys -X rectangle-toggle \; send -X begin-selection
bind -T copy-mode-vi n send-keys -X search-forward "» "
bind -T copy-mode-vi p send-keys -X search-backward "» "
bind -T copy-mode-vi / command-prompt -i -I "#{pane_search_string}" -p "(search down)" { send -X search-forward-incremental '%%%' }
bind -T copy-mode-vi ? command-prompt -i -I "#{pane_search_string}" -p "(search up)" { send -X search-backward-incremental '%%%' }
%if "#{!=:$EDITOR,}"
set editor $EDITOR
bind -T copy-mode-vi C-f send-keys -X pipe-and-cancel 'xargs -I% tmux send-keys $EDITOR Space % Enter'
%endif
Which means in both case you can edit a command or a visual selection in your $EDITOR
using ^f
.