2014-04-10 00:59:58 +08:00
|
|
|
function fish_vi_key_bindings --description 'vi-like key bindings for fish'
|
2014-01-20 20:07:32 +08:00
|
|
|
bind --erase --all
|
2014-04-10 00:59:58 +08:00
|
|
|
set -l init_mode insert
|
|
|
|
if set -q argv[1]
|
|
|
|
set init_mode $argv[1]
|
|
|
|
end
|
|
|
|
|
2014-01-20 20:07:32 +08:00
|
|
|
|
|
|
|
##
|
|
|
|
## command mode
|
|
|
|
##
|
|
|
|
|
|
|
|
bind :q exit
|
|
|
|
|
|
|
|
#
|
|
|
|
# normal (default) mode
|
|
|
|
#
|
|
|
|
|
|
|
|
bind \cd exit
|
2014-10-20 02:55:58 +08:00
|
|
|
bind \cc 'commandline ""'
|
2014-01-20 20:07:32 +08:00
|
|
|
bind h backward-char
|
|
|
|
bind l forward-char
|
|
|
|
bind \e\[C forward-char
|
|
|
|
bind \e\[D backward-char
|
2015-09-01 17:46:54 +08:00
|
|
|
|
|
|
|
# Some linux VTs output these (why?)
|
|
|
|
bind \eOC forward-char
|
|
|
|
bind \eOD backward-char
|
|
|
|
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -k right forward-char
|
|
|
|
bind -k left backward-char
|
2015-04-09 01:31:26 +08:00
|
|
|
bind -m insert \n execute
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -m insert i force-repaint
|
|
|
|
bind -m insert I beginning-of-line force-repaint
|
|
|
|
bind -m insert a forward-char force-repaint
|
|
|
|
bind -m insert A end-of-line force-repaint
|
|
|
|
bind -m visual v begin-selection force-repaint
|
|
|
|
|
|
|
|
#bind -m insert o "commandline -a \n" down-line force-repaint
|
|
|
|
#bind -m insert O beginning-of-line "commandline -i \n" up-line force-repaint # doesn't work
|
|
|
|
|
|
|
|
bind gg beginning-of-buffer
|
|
|
|
bind G end-of-buffer
|
|
|
|
|
|
|
|
bind \x24 end-of-line
|
|
|
|
bind \x5e beginning-of-line
|
2014-04-02 05:11:50 +08:00
|
|
|
bind 0 beginning-of-line
|
2014-01-20 20:07:32 +08:00
|
|
|
bind g\x24 end-of-line
|
|
|
|
bind g\x5e beginning-of-line
|
|
|
|
bind \e\[H beginning-of-line
|
|
|
|
bind \e\[F end-of-line
|
|
|
|
|
|
|
|
bind u history-search-backward
|
|
|
|
bind \cr history-search-forward
|
|
|
|
|
|
|
|
bind [ history-token-search-backward
|
|
|
|
bind ] history-token-search-forward
|
|
|
|
|
|
|
|
bind k up-or-search
|
|
|
|
bind j down-or-search
|
|
|
|
bind \e\[A up-or-search
|
|
|
|
bind \e\[B down-or-search
|
|
|
|
bind -k down down-or-search
|
|
|
|
bind -k up up-or-search
|
2015-09-01 17:46:54 +08:00
|
|
|
bind \eOA up-or-search
|
|
|
|
bind \eOB down-or-search
|
2014-01-20 20:07:32 +08:00
|
|
|
|
|
|
|
bind b backward-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind B backward-bigword
|
|
|
|
bind ge backward-word
|
|
|
|
bind gE backward-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
bind w forward-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind W forward-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
bind e forward-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind E forward-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
|
|
|
|
bind x delete-char
|
|
|
|
bind X backward-delete-char
|
|
|
|
|
|
|
|
bind -k dc delete-char
|
|
|
|
|
|
|
|
bind -k backspace backward-delete-char
|
|
|
|
bind \x7f backward-delete-char
|
|
|
|
bind \e\[3\;2~ backward-delete-char # Mavericks Terminal.app shift-delete
|
|
|
|
|
|
|
|
bind dd kill-whole-line
|
|
|
|
bind D kill-line
|
|
|
|
bind d\x24 kill-line
|
|
|
|
bind d\x5e backward-kill-line
|
|
|
|
bind dw kill-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind dW kill-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
bind diw forward-char forward-char backward-word kill-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind diW forward-char forward-char backward-bigword kill-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
bind daw forward-char forward-char backward-word kill-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind daW forward-char forward-char backward-bigword kill-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
bind de kill-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind dE kill-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
bind db backward-kill-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind dB backward-kill-bigword
|
|
|
|
bind dge backward-kill-word
|
|
|
|
bind dgE backward-kill-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
|
|
|
|
bind -m insert s delete-char force-repaint
|
|
|
|
bind -m insert S kill-whole-line force-repaint
|
|
|
|
bind -m insert cc kill-whole-line force-repaint
|
|
|
|
bind -m insert C kill-line force-repaint
|
|
|
|
bind -m insert c\x24 kill-line force-repaint
|
|
|
|
bind -m insert c\x5e backward-kill-line force-repaint
|
|
|
|
bind -m insert cw kill-word force-repaint
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind -m insert cW kill-bigword force-repaint
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -m insert ciw forward-char forward-char backward-word kill-word force-repaint
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind -m insert ciW forward-char forward-char backward-bigword kill-bigword force-repaint
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -m insert caw forward-char forward-char backward-word kill-word force-repaint
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind -m insert caW forward-char forward-char backward-bigword kill-bigword force-repaint
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -m insert ce kill-word force-repaint
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind -m insert cE kill-bigword force-repaint
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -m insert cb backward-kill-word force-repaint
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind -m insert cB backward-kill-bigword force-repaint
|
|
|
|
bind -m insert cge backward-kill-word force-repaint
|
|
|
|
bind -m insert cgE backward-kill-bigword force-repaint
|
2014-01-20 20:07:32 +08:00
|
|
|
|
|
|
|
bind '~' capitalize-word
|
|
|
|
bind gu downcase-word
|
|
|
|
bind gU upcase-word
|
|
|
|
|
|
|
|
bind J end-of-line delete-char
|
|
|
|
bind K 'man (commandline -t) ^/dev/null; or echo -n \a'
|
|
|
|
|
|
|
|
bind yy kill-whole-line yank
|
|
|
|
bind Y kill-whole-line yank
|
|
|
|
bind y\x24 kill-line yank
|
|
|
|
bind y\x5e backward-kill-line yank
|
|
|
|
bind yw kill-word yank
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind yW kill-bigword yank
|
2014-01-20 20:07:32 +08:00
|
|
|
bind yiw forward-char forward-char backward-word kill-word yank
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind yiW forward-char forward-char backward-bigword kill-bigword yank
|
2014-01-20 20:07:32 +08:00
|
|
|
bind yaw forward-char forward-char backward-word kill-word yank
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind yaW forward-char forward-char backward-bigword kill-bigword yank
|
2014-01-20 20:07:32 +08:00
|
|
|
bind ye kill-word yank
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind yE kill-bigword yank
|
2014-01-20 20:07:32 +08:00
|
|
|
bind yb backward-kill-word yank
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind yB backward-kill-bigword yank
|
|
|
|
bind yge backward-kill-word yank
|
|
|
|
bind ygE backward-kill-bigword yank
|
2014-01-20 20:07:32 +08:00
|
|
|
|
2014-01-22 17:00:44 +08:00
|
|
|
bind f forward-jump
|
|
|
|
bind F backward-jump
|
2014-01-23 17:23:04 +08:00
|
|
|
bind t forward-jump and backward-char
|
|
|
|
bind T backward-jump and forward-char
|
2014-01-22 17:00:44 +08:00
|
|
|
|
2014-01-20 20:07:32 +08:00
|
|
|
# in emacs yank means paste
|
|
|
|
bind p yank
|
|
|
|
bind P backward-char yank
|
|
|
|
bind gp yank-pop
|
|
|
|
|
|
|
|
bind '"*p' "commandline -i ( xsel -p; echo )[1]"
|
|
|
|
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
|
|
|
|
|
2015-09-01 17:46:54 +08:00
|
|
|
# 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
|
|
|
|
|
2014-01-20 20:07:32 +08:00
|
|
|
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
|
|
|
|
|
2014-05-29 01:40:39 +08:00
|
|
|
# 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
|
2014-05-29 18:02:02 +08:00
|
|
|
bind -M insert \cb backward-word
|
|
|
|
bind -M insert \cf forward-word
|
2014-05-29 01:40:39 +08:00
|
|
|
|
2015-08-04 20:22:55 +08:00
|
|
|
bind -M insert -m default \cc force-repaint
|
2014-04-02 04:59:24 +08:00
|
|
|
bind -M insert -m default \e backward-char force-repaint
|
2014-01-20 20:07:32 +08:00
|
|
|
|
|
|
|
bind -M insert \cd exit
|
|
|
|
|
|
|
|
bind -M insert \ef forward-word
|
|
|
|
|
2015-07-20 15:18:56 +08:00
|
|
|
#
|
|
|
|
# Lowercase r, enters replace-one mode
|
|
|
|
#
|
2014-01-20 20:07:32 +08:00
|
|
|
|
2015-07-20 15:18:56 +08:00
|
|
|
bind -m replace-one r force-repaint
|
|
|
|
bind -M replace-one -m default '' delete-char self-insert backward-char force-repaint
|
|
|
|
bind -M replace-one -m default \e cancel force-repaint
|
2014-01-20 20:07:32 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# visual mode
|
|
|
|
#
|
|
|
|
|
|
|
|
bind -M visual \e\[C forward-char
|
|
|
|
bind -M visual \e\[D backward-char
|
|
|
|
bind -M visual -k right forward-char
|
|
|
|
bind -M visual -k left backward-char
|
2015-09-01 17:46:54 +08:00
|
|
|
bind -M insert \eOC forward-char
|
|
|
|
bind -M insert \eOD backward-char
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -M visual h backward-char
|
|
|
|
bind -M visual l forward-char
|
|
|
|
|
|
|
|
bind -M visual b backward-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind -M visual B backward-bigword
|
|
|
|
bind -M visual ge backward-word
|
|
|
|
bind -M visual gE backward-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -M visual w forward-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind -M visual W forward-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
bind -M visual e forward-word
|
Add 'bigword' vi key bindings
- Add four new functions: forward-bigword, backward-bigword,
kill-bigword, backward-kill-bigword
- Add new enum move_word_style_whitespace and related state machine
method
- Change vi key bindings to operate on bigwords: B, gE, W, E, dW, diW,
daW, dE, dB, dgE, cW, ciW, caW, cE, cB, cgE, yW, yiW, yaW, yE, yB,
ygE
2015-05-31 06:44:25 +08:00
|
|
|
bind -M visual E forward-bigword
|
2014-01-20 20:07:32 +08:00
|
|
|
|
|
|
|
bind -M visual -m default d kill-selection end-selection force-repaint
|
|
|
|
bind -M visual -m default x kill-selection end-selection force-repaint
|
|
|
|
bind -M visual -m default X kill-whole-line end-selection force-repaint
|
|
|
|
bind -M visual -m default y kill-selection yank end-selection force-repaint
|
|
|
|
bind -M visual -m default '"*y' "commandline -s | xsel -p" end-selection force-repaint
|
|
|
|
|
|
|
|
bind -M visual -m default \cc end-selection force-repaint
|
|
|
|
bind -M visual -m default \e end-selection force-repaint
|
2014-01-18 03:32:24 +08:00
|
|
|
|
2014-04-10 00:59:58 +08:00
|
|
|
set fish_bind_mode $init_mode
|
2013-12-31 08:52:41 +08:00
|
|
|
end
|