Add replace mode in vi-mode

This commit is contained in:
0x005c
2019-11-23 13:30:19 +09:00
committed by ridiculousfish
parent 267b8da935
commit 48dc9b1e82
2 changed files with 15 additions and 0 deletions

View File

@@ -12,6 +12,9 @@ function fish_default_mode_prompt --description "Display the default mode for th
case replace_one
set_color --bold --background green white
echo '[R]'
case replace
set_color --bold --background cyan white
echo '[R]'
case visual
set_color --bold --background magenta white
echo '[V]'

View File

@@ -218,6 +218,17 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
bind -s --preset -M replace_one -m default \r 'commandline -f delete-char; commandline -i \n; commandline -f backward-char; commandline -f repaint-mode'
bind -s --preset -M replace_one -m default \e cancel repaint-mode
#
# Uppercase R, enters replace mode
#
bind -s --preset -m replace R repaint-mode
bind -s --preset -M replace '' delete-char self-insert
bind -s --preset -M replace -m insert \r execute repaint-mode
bind -s --preset -M replace -m default \e cancel repaint-mode
# in vim (and maybe in vi), <BS> deletes the changes
# but this binding just move cursor backward, not delete the changes
bind -s --preset -M replace -k backspace backward-char
#
# visual mode
#
@@ -263,6 +274,7 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish'
# the commenting chars so the command can be further edited then executed.
bind -s --preset -M default \# __fish_toggle_comment_commandline
bind -s --preset -M visual \# __fish_toggle_comment_commandline
bind -s --preset -M replace \# __fish_toggle_comment_commandline
# Set the cursor shape
# After executing once, this will have defined functions listening for the variable.