2014-04-10 00:59:58 +08:00
function fish_vi_key_bindings --description 'vi-like key bindings for fish'
2024-03-30 23:10:12 +08:00
set -l legacy_bind bind
2016-11-14 06:07:03 +08:00
if contains -- -h $argv
or contains -- --help $argv
2022-04-04 11:57:55 +08:00
echo "Sorry but this function doesn't support -h or --help" > & 2
2016-11-14 06:07:03 +08:00
return 1
end
2016-09-05 06:47:37 +08:00
# Erase all bindings if not explicitly requested otherwise to
# allow for hybrid bindings.
# This needs to be checked here because if we are called again
# via the variable handler the argument will be gone.
2016-11-16 07:47:19 +08:00
set -l rebind true
2020-03-10 02:36:12 +08:00
if test " $argv [1] " = --no-erase
2016-11-16 07:47:19 +08:00
set rebind false
2016-09-05 06:47:37 +08:00
set -e argv [ 1 ]
2016-11-16 07:47:19 +08:00
else
2018-09-18 17:52:25 +08:00
bind --erase --all --preset # clear earlier bindings, if any
2016-05-25 19:09:33 +08:00
end
2016-09-05 06:47:37 +08:00
# Allow just calling this function to correctly set the bindings.
# Because it's a rather discoverable name, users will execute it
# and without this would then have subtly broken bindings.
2020-03-10 02:36:12 +08:00
if test " $fish_key_bindings " != fish_vi_key_bindings
and test " $rebind " = true
2023-01-11 01:27:15 +08:00
# Allow the user to set the variable universally
set -l scope
2016-09-05 06:47:37 +08:00
set -q fish_key_bindings
2023-01-11 01:27:15 +08:00
or set scope -g
true
# We try to use `set --no-event`, but to avoid leaving the user without bindings
# if they run this with an older version we fall back on setting the variable
# with an event.
if ! set --no-event $scope fish_key_bindings fish_vi_key_bindings 2 > /dev/null
# This triggers the handler, which calls us again
set $scope fish_key_bindings fish_vi_key_bindings
# unless the handler somehow doesn't exist, which would leave us without bindings.
# this happens in no-config mode.
functions -q __fish_reload_key_bindings
and return
end
2016-09-05 06:47:37 +08:00
end
2016-03-30 06:33:37 +08:00
set -l init_mode insert
2016-09-04 01:27:42 +08:00
# These are only the special vi-style keys
# not end/home, we share those.
2024-03-30 23:10:12 +08:00
set -l eol_keys \$ g,\$
2016-09-04 01:27:42 +08:00
set -l bol_keys \^ 0 g\^
2016-09-05 06:47:37 +08:00
if contains -- $argv [ 1 ] insert default visual
2016-03-30 07:42:58 +08:00
set init_mode $argv [ 1 ]
2016-09-05 06:47:37 +08:00
else if set -q argv [ 1 ]
# We should still go on so the bindings still get set.
echo " Unknown argument $argv " > & 2
2016-03-30 06:33:37 +08:00
end
2016-05-25 19:09:33 +08:00
# Inherit shared key bindings.
2016-03-30 06:33:37 +08:00
# Do this first so vi-bindings win over default.
2016-05-25 19:09:33 +08:00
for mode in insert default visual
2019-04-30 17:40:52 +08:00
__fish_shared_key_bindings -s -M $mode
2016-05-25 19:09:33 +08:00
end
2016-03-30 06:33:37 +08:00
# Add a way to switch from insert to normal (command) mode.
2017-02-01 02:58:06 +08:00
# Note if we are paging, we want to stay in insert mode
# See #2871
2024-03-30 23:10:12 +08:00
set -l on_escape '
2024-03-22 17:34:48 +08:00
if commandline -P
commandline -f cancel
else
set fish_bind_mode default
if test ( count ( commandline --cut-at-cursor | tail -c2 ) ) != 2
commandline -f backward-char
end
commandline -f repaint-mode
end
'
2024-03-30 23:10:12 +08:00
bind -s --preset -M insert escape $on_escape
bind -s --preset -M insert ctrl-\[ $on_escape
2016-03-30 06:33:37 +08:00
2016-04-14 10:46:18 +08:00
# Default (command) mode
2024-03-30 23:10:12 +08:00
bind -s --preset :,q exit
bind -s --preset -m insert ctrl-c cancel-commandline repaint-mode
2018-12-14 00:33:48 +08:00
bind -s --preset -M default h backward-char
bind -s --preset -M default l forward-char
2024-03-30 23:10:12 +08:00
bind -s --preset -m insert enter execute
bind -s --preset -m insert ctrl-j execute
bind -s --preset -m insert ctrl-m execute
2024-02-14 18:25:25 +08:00
bind -s --preset -m insert o 'set fish_cursor_end_mode exclusive' insert-line-under repaint-mode
2024-03-30 23:10:12 +08:00
bind -s --preset -m insert O 'set fish_cursor_end_mode exclusive' insert-line-over repaint-mode
2019-04-01 21:52:21 +08:00
bind -s --preset -m insert i repaint-mode
bind -s --preset -m insert I beginning-of-line repaint-mode
2024-02-14 18:25:25 +08:00
bind -s --preset -m insert a 'set fish_cursor_end_mode exclusive' forward-single-char repaint-mode
bind -s --preset -m insert A 'set fish_cursor_end_mode exclusive' end-of-line repaint-mode
2019-04-01 21:52:21 +08:00
bind -s --preset -m visual v begin-selection repaint-mode
2018-12-14 00:33:48 +08:00
2024-03-30 23:10:12 +08:00
bind -s --preset g ,g beginning-of-buffer
2018-12-14 00:33:48 +08:00
bind -s --preset G end-of-buffer
2016-03-30 06:33:37 +08:00
for key in $eol_keys
2018-12-14 00:33:48 +08:00
bind -s --preset $key end-of-line
2016-03-30 06:33:37 +08:00
end
for key in $bol_keys
2018-12-14 00:33:48 +08:00
bind -s --preset $key beginning-of-line
2016-03-30 06:33:37 +08:00
end
2021-04-08 00:06:15 +08:00
bind -s --preset u undo
2024-03-30 23:10:12 +08:00
bind -s --preset ctrl -r redo
2016-03-30 06:33:37 +08:00
2018-12-14 00:33:48 +08:00
bind -s --preset [ history -token-search-backward
bind - s - - preset ] history -token-search-forward
2023-12-10 17:37:05 +08:00
bind -s --preset -m insert / history -pager repaint-mode
2016-03-30 06:33:37 +08:00
2018-12-14 00:33:48 +08:00
bind -s --preset k up-or-search
bind -s --preset j down-or-search
bind -s --preset b backward-word
bind -s --preset B backward-bigword
2024-03-30 23:10:12 +08:00
bind -s --preset g ,e backward-word
bind -s --preset g ,E backward-bigword
2020-07-21 21:08:38 +08:00
bind -s --preset w forward-word forward-single-char
bind -s --preset W forward-bigword forward-single-char
2024-02-14 18:25:25 +08:00
bind -s --preset e 'set fish_cursor_end_mode exclusive' forward-single-char forward-word backward-char 'set fish_cursor_end_mode inclusive'
bind -s --preset E 'set fish_cursor_end_mode exclusive' forward-single-char forward-bigword backward-char 'set fish_cursor_end_mode inclusive'
2016-03-30 06:33:37 +08:00
2024-03-30 23:10:12 +08:00
bind -s --preset -M insert ctrl-n accept-autosuggestion
2024-03-02 17:53:12 +08:00
2017-01-16 03:11:38 +08:00
# Vi/Vim doesn't support these keys in insert mode but that seems silly so we do so anyway.
2021-10-07 10:24:36 +08:00
bind -s --preset -M insert -k home beginning-of-line
bind -s --preset -M default -k home beginning-of-line
bind -s --preset -M insert -k end end -of-line
bind -s --preset -M default -k end end -of-line
2017-01-16 03:11:38 +08:00
2017-04-20 04:59:53 +08:00
# Vi moves the cursor back if, after deleting, it is at EOL.
# To emulate that, move forward, then backward, which will be a NOP
# if there is something to move forward to.
2024-02-14 18:25:25 +08:00
bind -s --preset -M default x delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
2018-12-14 00:33:48 +08:00
bind -s --preset -M default X backward-delete-char
2020-07-21 21:08:38 +08:00
bind -s --preset -M insert -k dc delete-char forward-single-char backward-char
2024-02-14 18:25:25 +08:00
bind -s --preset -M default -k dc delete-char 'set fish_cursor_end_mode exclusive' forward-single-char backward-char 'set fish_cursor_end_mode inclusive'
2016-03-30 06:33:37 +08:00
2016-08-05 02:40:21 +08:00
# Backspace deletes a char in insert mode, but not in normal/default mode.
2024-03-30 23:10:12 +08:00
bind -s --preset -M insert backspace backward-delete-char
bind -s --preset -M insert shift-backspace backward-delete-char
$legacy_bind -s --preset -M insert -k backspace backward-delete-char
bind -s --preset -M default backspace backward-char
$legacy_bind -s --preset -M default -k backspace backward-char
bind -s --preset -M insert ctrl-h backward-delete-char
bind -s --preset -M default ctrl-h backward-char
bind -s --preset d ,d kill -whole-line
2018-12-14 00:33:48 +08:00
bind -s --preset D kill -line
2024-03-30 23:10:12 +08:00
bind -s --preset d ,\$ kill -line
bind -s --preset d ,\^ backward-kill -line
bind -s --preset d ,0 backward-kill -line
bind -s --preset d ,w kill -word
bind -s --preset d ,W kill -bigword
bind -s --preset d ,i,w forward-single-char forward-single-char backward-word kill -word
bind -s --preset d ,i,W forward-single-char forward-single-char backward-bigword kill -bigword
bind -s --preset d ,a,w forward-single-char forward-single-char backward-word kill -word
bind -s --preset d ,a,W forward-single-char forward-single-char backward-bigword kill -bigword
bind -s --preset d ,e kill -word
bind -s --preset d ,E kill -bigword
bind -s --preset d ,b backward-kill -word
bind -s --preset d ,B backward-kill -bigword
bind -s --preset d ,g,e backward-kill -word
bind -s --preset d ,g,E backward-kill -bigword
bind -s --preset d ,f begin-selection forward-jump kill -selection end-selection
bind -s --preset d ,t begin-selection forward-jump backward-char kill -selection end-selection
bind -s --preset d ,F begin-selection backward-jump kill -selection end-selection
bind -s --preset d ,T begin-selection backward-jump forward-single-char kill -selection end-selection
bind -s --preset d ,h backward-char delete-char
bind -s --preset d ,l delete-char
2024-06-29 06:01:45 +08:00
bind -s --preset d ,i,b jump-till-matching-bracket and jump-till-matching-bracket and begin -selection jump-till-matching-bracket kill -selection end-selection
bind -s --preset d ,a,b jump-to-matching-bracket and jump-to-matching-bracket and begin -selection jump-to-matching-bracket kill -selection end-selection
2024-03-30 23:10:12 +08:00
bind -s --preset d ,i backward-jump-till and repeat-jump-reverse and begin -selection repeat-jump kill -selection end-selection
bind -s --preset d ,a backward-jump and repeat-jump-reverse and begin -selection repeat-jump kill -selection end-selection
bind -s --preset 'd,;' begin-selection repeat-jump kill -selection end-selection
bind -s --preset 'd,comma' begin-selection repeat-jump-reverse kill -selection end-selection
2018-12-14 00:33:48 +08:00
2019-04-01 21:52:21 +08:00
bind -s --preset -m insert s delete-char repaint-mode
2022-05-31 11:12:24 +08:00
bind -s --preset -m insert S kill -inner-line repaint-mode
2024-03-30 23:10:12 +08:00
bind -s --preset -m insert c,c kill -inner-line repaint-mode
2019-04-01 21:52:21 +08:00
bind -s --preset -m insert C kill -line repaint-mode
2024-03-30 23:10:12 +08:00
bind -s --preset -m insert c,\$ kill -line repaint-mode
bind -s --preset -m insert c,\^ backward-kill -line repaint-mode
bind -s --preset -m insert c,0 backward-kill -line repaint-mode
bind -s --preset -m insert c,w kill -word repaint-mode
bind -s --preset -m insert c,W kill -bigword repaint-mode
bind -s --preset -m insert c,i,w forward-single-char forward-single-char backward-word kill -word repaint-mode
bind -s --preset -m insert c,i,W forward-single-char forward-single-char backward-bigword kill -bigword repaint-mode
bind -s --preset -m insert c,a,w forward-single-char forward-single-char backward-word kill -word repaint-mode
bind -s --preset -m insert c,a,W forward-single-char forward-single-char backward-bigword kill -bigword repaint-mode
bind -s --preset -m insert c,e kill -word repaint-mode
bind -s --preset -m insert c,E kill -bigword repaint-mode
bind -s --preset -m insert c,b backward-kill -word repaint-mode
bind -s --preset -m insert c,B backward-kill -bigword repaint-mode
bind -s --preset -m insert c,g,e backward-kill -word repaint-mode
bind -s --preset -m insert c,g,E backward-kill -bigword repaint-mode
bind -s --preset -m insert c,f begin-selection forward-jump kill -selection end-selection repaint-mode
bind -s --preset -m insert c,t begin-selection forward-jump backward-char kill -selection end-selection repaint-mode
bind -s --preset -m insert c,F begin-selection backward-jump kill -selection end-selection repaint-mode
bind -s --preset -m insert c,T begin-selection backward-jump forward-single-char kill -selection end-selection repaint-mode
bind -s --preset -m insert c,h backward-char begin-selection kill -selection end-selection repaint-mode
bind -s --preset -m insert c,l begin-selection kill -selection end-selection repaint-mode
2024-06-29 06:01:45 +08:00
bind -s --preset -m insert c,i,b jump-till-matching-bracket and jump-till-matching-bracket and begin -selection jump-till-matching-bracket kill -selection end-selection
bind -s --preset -m insert c,a,b jump-to-matching-bracket and jump-to-matching-bracket and begin -selection jump-to-matching-bracket kill -selection end-selection
2024-03-30 23:10:12 +08:00
bind -s --preset -m insert c,i backward-jump-till and repeat-jump-reverse and begin -selection repeat-jump kill -selection end-selection repaint-mode
bind -s --preset -m insert c,a backward-jump and repeat-jump-reverse and begin -selection repeat-jump kill -selection end-selection repaint-mode
2018-12-14 00:33:48 +08:00
2020-07-21 21:08:38 +08:00
bind -s --preset '~' togglecase-char forward-single-char
2024-03-30 23:10:12 +08:00
bind -s --preset g ,u downcase-word
bind -s --preset g ,U upcase-word
2018-12-14 00:33:48 +08:00
bind -s --preset J end-of-line delete-char
bind -s --preset K 'man (commandline -t) 2>/dev/null; or echo -n \a'
bind -s --preset yy kill -whole-line yank
2024-04-09 05:03:15 +08:00
for seq in '",*,y,y' '",*,Y' '",+,y,y' '",+,Y'
2024-03-23 21:23:53 +08:00
bind -s --preset $seq fish_clipboard_copy
end
2018-12-14 00:33:48 +08:00
bind -s --preset Y kill -whole-line yank
2024-03-30 23:10:12 +08:00
bind -s --preset y ,\$ kill -line yank
bind -s --preset y ,\^ backward-kill -line yank
bind -s --preset y ,0 backward-kill -line yank
bind -s --preset y ,w kill -word yank
bind -s --preset y ,W kill -bigword yank
bind -s --preset y ,i,w forward-single-char forward-single-char backward-word kill -word yank
bind -s --preset y ,i,W forward-single-char forward-single-char backward-bigword kill -bigword yank
bind -s --preset y ,a,w forward-single-char forward-single-char backward-word kill -word yank
bind -s --preset y ,a,W forward-single-char forward-single-char backward-bigword kill -bigword yank
bind -s --preset y ,e kill -word yank
bind -s --preset y ,E kill -bigword yank
bind -s --preset y ,b backward-kill -word yank
bind -s --preset y ,B backward-kill -bigword yank
bind -s --preset y ,g,e backward-kill -word yank
bind -s --preset y ,g,E backward-kill -bigword yank
bind -s --preset y ,f begin-selection forward-jump kill -selection yank end-selection
bind -s --preset y ,t begin-selection forward-jump-till kill -selection yank end-selection
bind -s --preset y ,F begin-selection backward-jump kill -selection yank end-selection
bind -s --preset y ,T begin-selection backward-jump-till kill -selection yank end-selection
bind -s --preset y ,h backward-char begin-selection kill -selection yank end-selection
bind -s --preset y ,l begin-selection kill -selection yank end-selection
2024-06-29 06:01:45 +08:00
bind -s --preset y ,i,b jump-till-matching-bracket and jump-till-matching-bracket and begin -selection jump-till-matching-bracket kill -selection yank end-selection
bind -s --preset y ,a,b jump-to-matching-bracket and jump-to-matching-bracket and begin -selection jump-to-matching-bracket kill -selection yank end-selection
2024-03-30 23:10:12 +08:00
bind -s --preset y ,i backward-jump-till and repeat-jump-reverse and begin -selection repeat-jump kill -selection yank end-selection
bind -s --preset y ,a backward-jump and repeat-jump-reverse and begin -selection repeat-jump kill -selection yank end-selection
2018-12-14 00:33:48 +08:00
2024-06-29 05:23:36 +08:00
bind -s --preset % jump-to-matching-bracket
2018-12-14 00:33:48 +08:00
bind -s --preset f forward-jump
bind -s --preset F backward-jump
bind -s --preset t forward-jump-till
bind -s --preset T backward-jump-till
bind -s --preset ';' repeat-jump
bind -s --preset , repeat-jump-reverse
2016-03-30 06:33:37 +08:00
# in emacs yank means paste
2021-03-21 22:54:37 +08:00
# in vim p means paste *after* current character, so go forward a char before pasting
# also in vim, P means paste *at* current position (like at '|' with cursor = line),
# \ so there's no need to go back a char, just paste it without moving
2024-02-14 18:25:25 +08:00
bind -s --preset p 'set -g fish_cursor_end_mode exclusive' forward-char 'set -g fish_cursor_end_modefish_cursor_end_modeinclusive' yank
2021-03-21 22:54:37 +08:00
bind -s --preset P yank
2024-03-30 23:10:12 +08:00
bind -s --preset g ,p yank-pop
2016-03-30 06:33:37 +08:00
2021-03-21 22:54:37 +08:00
# same vim 'pasting' note as upper
2024-03-30 23:10:12 +08:00
bind -s --preset '",*,p' 'set -g fish_cursor_end_mode exclusive' forward-char 'set -g fish_cursor_end_mode inclusive' fish_clipboard_paste
bind -s --preset '",*,P' fish_clipboard_paste
bind -s --preset '",+,p' 'set -g fish_cursor_end_mode exclusive' forward-char 'set -g fish_cursor_end_mode inclusive' fish_clipboard_paste
bind -s --preset '",+,P' fish_clipboard_paste
2016-03-30 06:33:37 +08:00
#
2017-04-17 19:47:40 +08:00
# Lowercase r, enters replace_one mode
2016-03-30 06:33:37 +08:00
#
2019-04-01 21:52:21 +08:00
bind -s --preset -m replace_one r repaint-mode
bind -s --preset -M replace_one -m default '' delete-char self-insert backward-char repaint-mode
2024-03-30 23:10:12 +08:00
bind -s --preset -M replace_one -m default enter 'commandline -f delete-char; commandline -i \n; commandline -f backward-char; commandline -f repaint-mode'
bind -s --preset -M replace_one -m default ctrl-j 'commandline -f delete-char; commandline -i \n; commandline -f backward-char; commandline -f repaint-mode'
bind -s --preset -M replace_one -m default ctrl-m 'commandline -f delete-char; commandline -i \n; commandline -f backward-char; commandline -f repaint-mode'
bind -s --preset -M replace_one -m default escape cancel repaint-mode
bind -s --preset -M replace_one -m default ctrl-\[ cancel repaint-mode
2016-03-30 06:33:37 +08:00
2019-11-23 12:30:19 +08:00
#
# Uppercase R, enters replace mode
#
bind -s --preset -m replace R repaint-mode
bind -s --preset -M replace '' delete-char self-insert
2024-03-30 23:10:12 +08:00
bind -s --preset -M replace -m insert enter execute repaint-mode
bind -s --preset -M replace -m insert ctrl-j execute repaint-mode
bind -s --preset -M replace -m insert ctrl-m execute repaint-mode
bind -s --preset -M replace -m default escape cancel repaint-mode
bind -s --preset -M replace -m default ctrl-\[ cancel repaint-mode
2019-11-23 12:30:19 +08:00
# in vim (and maybe in vi), <BS> deletes the changes
# but this binding just move cursor backward, not delete the changes
2024-03-30 23:10:12 +08:00
bind -s --preset -M replace backspace backward-char
bind -s --preset -M replace shift-backspace backward-char
$legacy_bind -s --preset -M replace -k backspace backward-char
2019-11-23 12:30:19 +08:00
2016-03-30 06:33:37 +08:00
#
# visual mode
#
2018-12-14 00:33:48 +08:00
bind -s --preset -M visual h backward-char
bind -s --preset -M visual l forward-char
bind -s --preset -M visual k up-line
bind -s --preset -M visual j down-line
bind -s --preset -M visual b backward-word
bind -s --preset -M visual B backward-bigword
2024-03-30 23:10:12 +08:00
bind -s --preset -M visual g,e backward-word
bind -s --preset -M visual g,E backward-bigword
2018-12-14 00:33:48 +08:00
bind -s --preset -M visual w forward-word
bind -s --preset -M visual W forward-bigword
2024-02-14 18:25:25 +08:00
bind -s --preset -M visual e 'set fish_cursor_end_mode exclusive' forward-single-char forward-word backward-char 'set fish_cursor_end_mode inclusive'
bind -s --preset -M visual E 'set fish_cursor_end_mode exclusive' forward-single-char forward-bigword backward-char 'set fish_cursor_end_mode inclusive'
2019-04-01 21:52:21 +08:00
bind -s --preset -M visual o swap-selection-start-stop repaint-mode
2018-12-14 00:33:48 +08:00
2024-06-29 05:23:36 +08:00
bind -s --preset -M visual % jump-to-matching-bracket
2018-12-14 00:33:48 +08:00
bind -s --preset -M visual f forward-jump
bind -s --preset -M visual t forward-jump-till
bind -s --preset -M visual F backward-jump
bind -s --preset -M visual T backward-jump-till
2018-01-27 00:36:18 +08:00
2016-03-30 06:33:37 +08:00
for key in $eol_keys
2018-12-14 00:33:48 +08:00
bind -s --preset -M visual $key end-of-line
2016-03-30 06:33:37 +08:00
end
for key in $bol_keys
2018-12-14 00:33:48 +08:00
bind -s --preset -M visual $key beginning-of-line
2016-03-30 06:33:37 +08:00
end
2019-04-01 21:52:21 +08:00
bind -s --preset -M visual -m insert c kill -selection end-selection repaint-mode
2021-06-01 07:46:33 +08:00
bind -s --preset -M visual -m insert s kill -selection end-selection repaint-mode
2024-06-12 18:11:40 +08:00
bind -s --preset -M visual -m default d kill -selection end-selection backward-char repaint-mode
2019-04-01 21:52:21 +08:00
bind -s --preset -M visual -m default x kill -selection end-selection repaint-mode
bind -s --preset -M visual -m default X kill -whole-line end-selection repaint-mode
bind -s --preset -M visual -m default y kill -selection yank end-selection repaint-mode
2024-03-30 23:10:12 +08:00
bind -s --preset -M visual -m default '",*,y' "fish_clipboard_copy; commandline -f end-selection repaint-mode"
bind -s --preset -M visual -m default '",+,y' "fish_clipboard_copy; commandline -f end-selection repaint-mode"
2020-04-17 11:24:25 +08:00
bind -s --preset -M visual -m default '~' togglecase-selection end-selection repaint-mode
2016-03-30 06:33:37 +08:00
2024-03-30 23:10:12 +08:00
bind -s --preset -M visual -m default ctrl-c end-selection repaint-mode
bind -s --preset -M visual -m default escape end-selection repaint-mode
bind -s --preset -M visual -m default ctrl-\[ end-selection repaint-mode
2016-03-30 06:33:37 +08:00
2016-04-17 11:03:14 +08:00
# Make it easy to turn an unexecuted command into a comment in the shell history. Also, remove
# the commenting chars so the command can be further edited then executed.
2018-12-14 00:33:48 +08:00
bind -s --preset -M default \# __fish_toggle_comment_commandline
bind -s --preset -M visual \# __fish_toggle_comment_commandline
2019-11-23 12:30:19 +08:00
bind -s --preset -M replace \# __fish_toggle_comment_commandline
2016-09-05 07:22:07 +08:00
# Set the cursor shape
# After executing once, this will have defined functions listening for the variable.
# Therefore it needs to be before setting fish_bind_mode.
fish_vi_cursor
2022-10-06 04:11:43 +08:00
set -g fish_cursor_selection_mode inclusive
2024-02-14 18:25:25 +08:00
function __fish_vi_key_bindings_on_mode_change --on-variable fish_bind_mode
switch $fish_bind_mode
case insert
set -g fish_cursor_end_mode exclusive
case '*'
set -g fish_cursor_end_mode inclusive
end
end
function __fish_vi_key_bindings_remove_handlers --on-variable __fish_active_key_bindings
functions --erase __fish_vi_key_bindings_remove_handlers
functions --erase __fish_vi_key_bindings_on_mode_change
functions --erase fish_vi_cursor_handle
functions --erase fish_vi_cursor_handle_preexec
set -e -g fish_cursor_end_mode
set -e -g fish_cursor_selection_mode
end
2016-09-05 07:22:07 +08:00
set fish_bind_mode $init_mode
2013-12-31 08:52:41 +08:00
end