From ad731e483019afd802660d976a8f5227f12ddf58 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Thu, 29 Dec 2011 23:13:44 -0500 Subject: [PATCH] Use the emacs keymap by default. Since keymaps emacs and viins are aliases to main, it is not necessary to define emacs keys twice. --- keyboard.zsh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/keyboard.zsh b/keyboard.zsh index eca51a9..ff4b20d 100644 --- a/keyboard.zsh +++ b/keyboard.zsh @@ -54,6 +54,17 @@ keyinfo=( 'BackTab' "$terminfo[kcbt]" ) +# Use Emacs bindings by default. +if ! zstyle -m ':omz:editor' keymap ' *'; then + zstyle ':omz:editor' keymap 'emacs' +fi + +# Stop binding on an invalid keymap. +if ! zstyle -m ':omz:editor' keymap 'emacs|vi'; then + print "omz: \`zstyle ':omz:editor' keymap\` must be set to 'emacs' or 'vi'" >&2 + return 1 +fi + if zstyle -m ':omz:editor' keymap 'emacs'; then # Use Emacs key bindings. bindkey -e @@ -109,7 +120,9 @@ if zstyle -m ':omz:editor' keymap 'emacs'; then [[ -n "$keyinfo[Control]" ]] && \ bindkey "$keyinfo[Control]s" history-incremental-search-forward fi -elif zstyle -m ':omz:editor' keymap 'vi'; then +fi + +if zstyle -m ':omz:editor' keymap 'vi'; then # Use vi key bindings. bindkey -v @@ -232,9 +245,6 @@ elif zstyle -m ':omz:editor' keymap 'vi'; then [[ -n "$keyinfo[Control]" ]] && \ bindkey -M viins "$keyinfo[Control]s" history-incremental-search-forward fi -else - print "omz: \`zstyle ':omz:editor' keymap\` must be set to 'emacs' or 'vi'" >&2 - return 1 fi # The next key bindings are for both Emacs and Vi.