-### aliases
-## generic abbreviations
-alias h="history -25"
-alias j="jobs -l"
-alias l="ls -AF"
-alias p="${PAGER:-more}" # TODO: make sure more is there or use safe default
-alias e="${EDITOR:-vi}" # TODO: make sure vi is there or use safe default
+## bind keys in both viins and vicmd modes
+typeset -A a
+a=(
+ #key viins vicmd
+ Backspace 'backward-delete-char vi-backward-char'
+ Insert 'overwrite-mode vi-insert'
+ Home 'beginning-of-line'
+ PageUp 'up-history -'
+ Delete 'delete-char'
+ End 'end-of-line'
+ PageDown 'down-history -'
+ Up 'up-line-or-beginning-search vi-up-line-or-history'
+ Down 'down-line-or-beginning-search vi-down-line-or-history'
+ Left 'backward-char'
+ Right 'forward-char'
+)
+for k v in ${(kv)a}; do
+ k=$key[$k]
+ if [[ -z "$k" ]] { continue }
+ v=($=v)
+ bindkey -- $k $v[1]
+ if [[ $v[2] == '-' ]] {
+ # copy viins to vicmd verbatim
+ bindkey -a -- $k $v[1]
+ } elif (( $#v != 1 )) {
+ # set vicmd to any other value
+ bindkey -a -- $k $v[2]
+ } else {
+ # copy viins to vicmd and prepend vi- to it
+ bindkey -a -- $k vi-$v[1]
+ }
+done
+unset a k v
+
+### abbreviation aliases
+alias h='history -25'
+alias j='jobs -l'
+alias l='ls -AF'