Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for vi mode #3

Merged
merged 1 commit into from
May 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions functions/_pisces_bind_pair.fish
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
function _pisces_bind_pair -a left right -d "Creates bindings for the given pair: autoclose and remove empty"
function _pisces_bind_pair -a mode left right -d "Creates bindings for the given pair: autoclose and remove empty"

test -z $mode
and set mode default

set l $left
set r $right
Expand All @@ -8,10 +11,10 @@ function _pisces_bind_pair -a left right -d "Creates bindings for the given pair

if [ $left = $right ]

bind $r "_pisces_skip $right; or _pisces_append $right"
bind -M $mode $r "_pisces_skip $right; or _pisces_append $right"
else # if $some_special_setting

bind $l "commandline -i -- $left; and _pisces_append $right"
bind $r "_pisces_skip $right"
bind -M $mode $l "commandline -i -- $left; and _pisces_append $right"
bind -M $mode $r "_pisces_skip $right"
end
end
13 changes: 9 additions & 4 deletions key_bindings.fish
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
function key_bindings

set -l _pisces_bind_mode default
if [ "$fish_key_bindings" = 'fish_vi_key_bindings' ]
set _pisces_bind_mode insert
end

set -q pisces_pairs
or set -U pisces_pairs '(,)' '[,]' '{,}' '","' "','"

for pair in $pisces_pairs
_pisces_bind_pair (string split -- ',' $pair)
_pisces_bind_pair $_pisces_bind_mode (string split -- ',' $pair)
end

# normal backspace, also known as \010 or ^H:
bind \b _pisces_backspace
bind -M $_pisces_bind_mode \b _pisces_backspace
# Terminal.app sends DEL code on ⌫:
bind \177 _pisces_backspace
bind -M $_pisces_bind_mode \177 _pisces_backspace

# overrides TAB to provide completion of vars before a closing '"'
bind \t _pisces_complete
bind -M $_pisces_bind_mode \t _pisces_complete
end