ec70c0c393e53004b885d146dd77b9a3f136971a

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

lib: bind keys to viins and vicmd keymaps and clean up file

Fixes #8468

Diff

This diff is truncated to protect this page.

  1diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh
  2index 0e056dc72e5d6e128a3c464cbf462b3fb3bd8e96..10053f6f3099c8a8838e5518cd39457d0c3ab30b 100644
  3--- a/lib/key-bindings.zsh
  4+++ b/lib/key-bindings.zsh
  5@@ -15,56 +15,87 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then
  6   zle -N zle-line-finish
  7 fi
  8 
  9-bindkey -e                                            # Use emacs key bindings
 10+# Use emacs key bindings
 11+bindkey -e
 12 
 13-bindkey '\ew' kill-region                             # [Esc-w] - Kill from the cursor to the mark
 14-bindkey -s '\el' 'ls\n'                               # [Esc-l] - run command: ls
 15-bindkey '^r' history-incremental-search-backward      # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line.
 16-if [[ "${terminfo[kpp]}" != "" ]]; then
 17-  bindkey "${terminfo[kpp]}" up-line-or-history       # [PageUp] - Up a line of history
 18+# [PageUp] - Up a line of history
 19+if [[ -n "${terminfo[kpp]}" ]]; then
 20+  bindkey -M emacs "${terminfo[kpp]}" up-line-or-history
 21+  bindkey -M viins "${terminfo[kpp]}" up-line-or-history
 22+  bindkey -M vicmd "${terminfo[kpp]}" up-line-or-history
 23 fi
 24-if [[ "${terminfo[knp]}" != "" ]]; then
 25-  bindkey "${terminfo[knp]}" down-line-or-history     # [PageDown] - Down a line of history
 26+# [PageDown] - Down a line of history
 27+if [[ -n "${terminfo[knp]}" ]]; then
 28+  bindkey -M emacs "${terminfo[knp]}" down-line-or-history
 29+  bindkey -M viins "${terminfo[knp]}" down-line-or-history
 30+  bindkey -M vicmd "${terminfo[knp]}" down-line-or-history
 31 fi
 32 
 33-# start typing + [Up-Arrow] - fuzzy find history forward
 34-if [[ "${terminfo[kcuu1]}" != "" ]]; then
 35+# Start typing + [Up-Arrow] - fuzzy find history forward
 36+if [[ -n "${terminfo[kcuu1]}" ]]; then
 37   autoload -U up-line-or-beginning-search
 38   zle -N up-line-or-beginning-search
 39-  bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search
 40+
 41+  bindkey -M emacs "${terminfo[kcuu1]}" up-line-or-beginning-search
 42+  bindkey -M viins "${terminfo[kcuu1]}" up-line-or-beginning-search
 43+  bindkey -M vicmd "${terminfo[kcuu1]}" up-line-or-beginning-search
 44 fi
 45-# start typing + [Down-Arrow] - fuzzy find history backward
 46-if [[ "${terminfo[kcud1]}" != "" ]]; then
 47+# Start typing + [Down-Arrow] - fuzzy find history backward
 48+if [[ -n "${terminfo[kcud1]}" ]]; then
 49   autoload -U down-line-or-beginning-search
 50   zle -N down-line-or-beginning-search
 51-  bindkey "${terminfo[kcud1]}" down-line-or-beginning-search
 52+
 53+  bindkey -M emacs "${terminfo[kcud1]}" down-line-or-beginning-search
 54+  bindkey -M viins "${terminfo[kcud1]}" down-line-or-beginning-search
 55+  bindkey -M vicmd "${terminfo[kcud1]}" down-line-or-beginning-search
 56 fi
 57 
 58-if [[ "${terminfo[khome]}" != "" ]]; then
 59-  bindkey "${terminfo[khome]}" beginning-of-line      # [Home] - Go to beginning of line
 60+# [Home] - Go to beginning of line
 61+if [[ -n "${terminfo[khome]}" ]]; then
 62+  bindkey -M emacs "${terminfo[khome]}" beginning-of-line
 63+  bindkey -M viins "${terminfo[khome]}" beginning-of-line
 64+  bindkey -M vicmd "${terminfo[khome]}" beginning-of-line
 65 fi
 66-if [[ "${terminfo[kend]}" != "" ]]; then
 67-  bindkey "${terminfo[kend]}"  end-of-line            # [End] - Go to end of line
 68+# [End] - Go to end of line
 69+if [[ -n "${terminfo[kend]}" ]]; then
 70+  bindkey -M emacs "${terminfo[kend]}"  end-of-line
 71+  bindkey -M viins "${terminfo[kend]}"  end-of-line
 72+  bindkey -M vicmd "${terminfo[kend]}"  end-of-line
 73 fi
 74 
 75-bindkey ' ' magic-space                               # [Space] - do history expansion
 76-
 77-bindkey '^[[1;5C' forward-word                        # [Ctrl-RightArrow] - move forward one word
 78-bindkey '^[[1;5D' backward-word                       # [Ctrl-LeftArrow] - move backward one word
 79-
 80-if [[ "${terminfo[kcbt]}" != "" ]]; then
 81-  bindkey "${terminfo[kcbt]}" reverse-menu-complete   # [Shift-Tab] - move through the completion menu backwards
 82+# [Shift-Tab] - move through the completion menu backwards
 83+if [[ -n "${terminfo[kcbt]}" ]]; then
 84+  bindkey -M emacs "${terminfo[kcbt]}" reverse-menu-complete
 85+  bindkey -M viins "${terminfo[kcbt]}" reverse-menu-complete
 86+  bindkey -M vicmd "${terminfo[kcbt]}" reverse-menu-complete
 87 fi
 88 
 89-bindkey '^?' backward-delete-char                     # [Backspace] - delete backward
 90-if [[ "${terminfo[kdch1]}" != "" ]]; then
 91-  bindkey "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward
 92+# [Backspace] - delete backward
 93+bindkey '^?' backward-delete-char
 94+# [Delete] - delete forward
 95+if [[ -n "${terminfo[kdch1]}" ]]; then
 96+  bindkey -M emacs "${terminfo[kdch1]}" delete-char            
 97+  bindkey -M viins "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward
 98+  bindkey -M vicmd "${terminfo[kdch1]}" delete-char            # [Delete] - delete forward
 99 else
100   bindkey "^[[3~" delete-char
101   bindkey "^[3;5~" delete-char
102-  bindkey "\e[3~" delete-char
103 fi
104