autoload -U history-substring-search-up autoload -U history-substring-search-down autoload -U up-line-or-beginning-search autoload -U down-line-or-beginning-search zle -N history-substring-search-up zle -N history-substring-search-down zle -N up-line-or-beginning-search zle -N down-line-or-beginning-search bindkey -v # Fix backspace not working after returning from cmd mode bindkey '^?' backward-delete-char bindkey '^h' backward-delete-char bindkey '^w' backward-kill-word # Even more ways to search bindkey '^P' up-line-or-beginning-search bindkey '^N' down-line-or-beginning-search bindkey '^U' history-incremental-pattern-search-backward bindkey '^F' fzf-history-widget bindkey -M viins '^K' up-history # ^K to previous command. bindkey -M viins '^J' down-history # ^J to next command. # Ctrl+Y is a standard in some places, and since Ctrl+R is taken... bindkey -a u undo bindkey -a '^y' redo # file rename magick bindkey "^[m" copy-prev-shell-word # Better searching in command mode bindkey -M vicmd '?' history-incremental-search-backward bindkey -M vicmd '/' history-incremental-search-forward bindkey -M vicmd 'k' history-substring-search-up bindkey -M vicmd 'j' history-substring-search-down bindkey -M vicmd '^K' up-history # ^K to previous command. bindkey -M vicmd '^J' down-history # ^J to next command. bindkey -M vicmd 'H' vi-beginning-of-line # Go beginning of line. bindkey -M vicmd 'L' vi-end-of-line # Go end of line. bindkey -M vicmd 'cr' change-surround # Change surround operator. bindkey -M vicmd 'dr' delete-surround # Delete surround operator. bindkey -M vicmd 'yr' add-surround # Add surround operator. typeset -g -A key key[Home]="$terminfo[khome]" key[End]="$terminfo[kend]" key[Insert]="$terminfo[kich1]" key[Backspace]="$terminfo[kbs]" key[Delete]="$terminfo[kdch1]" key[Up]="$terminfo[kcuu1]" key[Down]="$terminfo[kcud1]" key[Left]="$terminfo[kcub1]" key[Right]="$terminfo[kcuf1]" key[PageUp]="$terminfo[kpp]" key[PageDown]="$terminfo[knp]" # setup key accordingly [[ -n "$key[Home]" ]] && bindkey -- "$key[Home]" beginning-of-line [[ -n "$key[End]" ]] && bindkey -- "$key[End]" end-of-line [[ -n "$key[Insert]" ]] && bindkey -- "$key[Insert]" overwrite-mode [[ -n "$key[Backspace]" ]] && bindkey -- "$key[Backspace]" backward-delete-char [[ -n "$key[Delete]" ]] && bindkey -- "$key[Delete]" delete-char [[ -n "$key[Up]" ]] && bindkey -- "$key[Up]" history-substring-search-up [[ -n "$key[Down]" ]] && bindkey -- "$key[Down]" history-substring-search-down [[ -n "$key[Left]" ]] && bindkey -- "$key[Left]" backward-char [[ -n "$key[Right]" ]] && bindkey -- "$key[Right]" forward-char [[ -n "$key[PageUp]" ]] && bindkey -- "$key[PageUp]" history-beginning-search-backward [[ -n "$key[PageDown]" ]] && bindkey -- "$key[PageDown]" history-beginning-search-forward # Runs bindkey but for all of the keymaps. Running it with no arguments will # print out the mappings for all of the keymaps. function bindkey-all { local keymap='' for keymap in $(bindkey -l); do [[ "$#" -eq 0 ]] && printf "#### %s\n" "${keymap}" 1>&2 bindkey -M "${keymap}" "$@" done } # Finally, make sure the terminal is in application mode, when zle is # active. Only then are the values from $terminfo valid. if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then function zle-line-init () { echoti smkx } function zle-line-finish () { echoti rmkx } zle -N zle-line-init zle -N zle-line-finish fi # ci" autoload -U select-quoted zle -N select-quoted for m in visual viopp; do for c in {a,i}{\',\",\`}; do bindkey -M $m $c select-quoted done done # ci{, ci(, di{ etc.. autoload -U select-bracketed zle -N select-bracketed for m in visual viopp; do for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do bindkey -M $m $c select-bracketed done done autoload edit-command-line; zle -N edit-command-line bindkey '^e' edit-command-line export KEYTIMEOUT=1