Skip to content

Commit

Permalink
feat: better exchange point(cursor) and mark
Browse files Browse the repository at this point in the history
When we are in the visual line mode, the behavior of using the `o`
key to move around mark and point(cursor) was weird, so here is an
implementation for solving the problem.
  • Loading branch information
jeffreytse committed Jan 7, 2021
1 parent f7a2a5e commit 5eb9f1d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions zsh-vi-mode.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ function zvm_kill_whole_line() {
MARK=$cpos
}

# Exchange the point and mark
function zvm_exchange_point_and_mark() {
cursor=$MARK
MARK=$CURSOR CURSOR=$cursor
zvm_highlight
}

# Open line below
function zvm_open_line_below() {
ZVM_MODE=$ZVM_MODE_INSERT
Expand Down Expand Up @@ -1068,6 +1075,7 @@ function zvm_init() {
zvm_define_widget zvm_exit_insert_mode
zvm_define_widget zvm_enter_visual_mode
zvm_define_widget zvm_exit_visual_mode
zvm_define_widget zvm_exchange_point_and_mark
zvm_define_widget zvm_open_line_below
zvm_define_widget zvm_open_line_above
zvm_define_widget zvm_vi_substitue
Expand Down Expand Up @@ -1118,6 +1126,7 @@ function zvm_init() {
zvm_bindkey vicmd 'v' zvm_enter_visual_mode
zvm_bindkey vicmd 'V' zvm_enter_visual_mode
zvm_bindkey visual '^[' zvm_exit_visual_mode
zvm_bindkey visual 'o' zvm_exchange_point_and_mark
zvm_bindkey vicmd 'o' zvm_open_line_below
zvm_bindkey vicmd 'O' zvm_open_line_above
zvm_bindkey vicmd 's' zvm_vi_substitue
Expand Down

0 comments on commit 5eb9f1d

Please sign in to comment.