diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2015-10-02 00:37:36 +0200 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2015-10-13 21:08:55 +0200 |
commit | c0e8ad6f1feff09474e957773a1508d9813d4bbb (patch) | |
tree | 7073334d159eb94329a354c2fc843a1eac84cbd8 | |
parent | 3472a39d07ea208d0de6285e5ded3ad0db0f31b3 (diff) |
Make vi bindings inherit the defaults
This reduces code duplication and adds some previously unavailable
bindings that don't quite _violate_ the vi-principle (like
prevd-or-backward-word on alt-left) and matches other "impure" bindings
like \cf for forward-word (a quite emacs-ish binding) we already have.
Fixes #2412
Fixes #2472
Fixes #2255
-rw-r--r-- | doc_src/index.hdr.in | 2 | ||||
-rw-r--r-- | share/functions/fish_vi_key_bindings.fish | 63 |
2 files changed, 9 insertions, 56 deletions
diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in index e9619f48..fdd5162f 100644 --- a/doc_src/index.hdr.in +++ b/doc_src/index.hdr.in @@ -912,7 +912,7 @@ You can change these key bindings using the <a href="commands.html#bind">bind</a \subsection vi-mode Vi mode commands -Vi mode allows for the use of Vi-like commands at the prompt. Initially, <a href="#vi-mode-insert">insert mode</a> is active. @key{Escape} enters <a href="#vi-mode-command">command mode</a>. The commands available in command, insert and visual mode are described below. +Vi mode allows for the use of Vi-like commands at the prompt. Initially, <a href="#vi-mode-insert">insert mode</a> is active. @key{Escape} enters <a href="#vi-mode-command">command mode</a>. The commands available in command, insert and visual mode are described below. Vi mode builds on top of <a href="#emacs-mode">Emacs mode</a>, so all keybindings mentioned there that do not contradict the ones mentioned here also work. \subsubsection vi-mode-command Command mode diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 202c2d48..7af9d4f8 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -5,6 +5,14 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' set init_mode $argv[1] end + # Inherit default key bindings + # Do this first so vi-bindings win over default + fish_default_key_bindings -M insert + fish_default_key_bindings -M default + + # Add a way to get out of insert mode + bind -M insert -m default \cc force-repaint + bind -M insert -m default \e backward-char force-repaint ## ## command mode @@ -157,61 +165,6 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' bind '"*P' backward-char "commandline -i ( xsel -p; echo )[1]" # - # insert mode - # - - bind -M insert "" self-insert - bind -M insert \n execute - - bind -M insert -k dc delete-char - - bind -M insert -k backspace backward-delete-char - bind -M insert \x7f backward-delete-char - # Mavericks Terminal.app shift-delete - bind -M insert \e\[3\;2~ backward-delete-char - - bind -M insert \t complete - - # OS X SnowLeopard doesn't have these keys. Don't show an annoying error message. - bind -M insert -k home beginning-of-line 2> /dev/null - bind -M insert -k end end-of-line 2> /dev/null - bind -M insert \e\[3\;2~ backward-delete-char # Mavericks Terminal.app shift-delete - - bind -M insert \cx end-of-line - - bind -M insert \e\[A up-or-search - bind -M insert \e\[B down-or-search - bind -M insert -k down down-or-search - bind -M insert -k up up-or-search - - # Some linux VTs output these (why?) - bind -M insert \eOA up-or-search - bind -M insert \eOB down-or-search - bind -M insert \eOC forward-char - bind -M insert \eOD backward-char - - bind -M insert \e\[C forward-char - bind -M insert \e\[D backward-char - bind -M insert -k right forward-char - bind -M insert -k left backward-char - - # useful insert mode mappings - bind -M insert \ch backward-delete-char - bind -M insert \cw backward-kill-word - bind -M insert \cu backward-kill-line - bind -M insert \cp history-search-backward - bind -M insert \cn history-search-forward - bind -M insert \cb backward-word - bind -M insert \cf forward-word - - bind -M insert -m default \cc force-repaint - bind -M insert -m default \e backward-char force-repaint - - bind -M insert \cd exit - - bind -M insert \ef forward-word - - # # Lowercase r, enters replace-one mode # |