-# TODO: Explain what some of this does..
+bindkey -v
-bindkey -e
-bindkey -s '\el' "ls\n"
-bindkey '\ew' kill-region
-bindkey '^r' history-incremental-search-backward
-bindkey "^[[5~" up-line-or-history
-bindkey "^[[6~" down-line-or-history
+bindkey '^N' history-search-forward
+bindkey '^P' history-search-backward
+bindkey ' ' magic-space # also do history expansion on space
-# make search up and down work, so partially type and hit up/down to find relevant stuff
-bindkey '^[[A' up-line-or-search # up arrow
-bindkey '^[[B' down-line-or-search # down arrow
-
-bindkey "^[[H" beginning-of-line
-bindkey "^[[1~" beginning-of-line
-bindkey "^[OH" beginning-of-line
-bindkey "\e[7~" beginning-of-line
-bindkey "^[[F" end-of-line
-bindkey "^[[4~" end-of-line
-bindkey "\e[8~" end-of-line
-bindkey "^[OF" end-of-line
-bindkey ' ' magic-space # also do history expansion on space
-
-bindkey "^[[1;5C" forward-word
-bindkey "^[[1;5D" backward-word
+bindkey -s '^[l' '^Qls\r' # show dir content
+bindkey -s '^Z' '^Qfg\r' # fg with ^Z
bindkey '^[[Z' reverse-menu-complete
+bindkey -M vicmd 'v' edit-command-line
+
+# delay after ESC (in 0.01s)
+export KEYTIMEOUT=40
+
+# fix Home/End keys
+bindkey '^[[7~' beginning-of-line
+bindkey '^[[8~' end-of-line
+
+# emacs bindings
+bindkey '^A' beginning-of-line
+bindkey '^B' backward-char
+bindkey '^E' end-of-line
+bindkey '^F' edit-command-line
+bindkey '^G' list-expand
+bindkey '^O' accept-line-and-down-history
+bindkey '^Q' push-input
+bindkey '^?' backward-delete-char
+bindkey '^H' backward-delete-char
+bindkey '^W' backward-kill-word
+bindkey '^X=' what-cursor-position
+bindkey '^[.' insert-last-word
+bindkey '^[?' which-command
+bindkey '^[A' accept-and-hold
+bindkey '^[a' accept-and-hold
+bindkey '^[C' capitalize-word
+bindkey '^[c' capitalize-word
+bindkey '^[H' run-help
+bindkey '^[h' run-help
+bindkey '^[T' transpose-words
+bindkey '^[t' transpose-words
+
+# make search up and down work, so partially type and hit up/down to find relevant stuff
+bindkey '^[[A' up-line-or-search # up arrow
+bindkey '^[[B' down-line-or-search # down arrow
+bindkey '^[[5~' up-line-or-history # PgUp
+bindkey '^[[6~' down-line-or-history # PgDown
+
+bindkey '^[OA' up-line-or-history
+bindkey '^[OB' down-line-or-history
+bindkey '^[OC' forward-char
+bindkey '^[OD' backward-char
+bindkey '^[OF' end-of-line
+bindkey '^[OH' beginning-of-line
+
+bindkey '\e[c' forward-word
+bindkey '\e[d' backward-word
+
# Make the delete key (or Fn + Delete on the Mac) work instead of outputting a ~
bindkey '^?' backward-delete-char
-bindkey "^[[3~" delete-char
-bindkey "^[3;5~" delete-char
-bindkey "\e[3~" delete-char
+bindkey '^[[3~' delete-char
+bindkey '^[3;5~' delete-char
+bindkey '\e[3~' delete-char