From 889b2b262800c17f462c62ddea2a290788c42087 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Wed, 29 Sep 2010 18:16:15 +0200 Subject: vim_mode: Don't move after last character in command mode. --- vim-mode/vim_mode.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 3cf1b7e..a42fc65 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -390,7 +390,7 @@ sub cmd_movement_l { my $length = _input_len(); $pos += $count; - $pos = $length if $pos > $length; + $pos = $length - 1 if $pos > $length - 1; _input_pos($pos); } sub cmd_movement_space { @@ -642,7 +642,7 @@ sub cmd_movement_caret { _input_pos($pos); } sub cmd_movement_dollar { - _input_pos(_input_len()); + _input_pos(_input_len() - 1); } sub cmd_movement_x { @@ -682,7 +682,13 @@ sub cmd_movement_I { sub cmd_movement_a { my ($count, $pos, $repeat) = @_; - cmd_movement_l(1, _input_pos()); + # Move after current character. Can't use cmd_movement_l() because we need + # to mover after last character at the end of the line. + my $length = _input_len(); + $pos += $count; + $pos = $length if $pos > $length; + _input_pos($pos); + if (!$repeat) { _update_mode(M_INS); } else { @@ -692,7 +698,8 @@ sub cmd_movement_a { sub cmd_movement_A { my ($count, $pos, $repeat) = @_; - cmd_movement_dollar(); + _input_pos(_input_len()); + if (!$repeat) { _update_mode(M_INS); } else { -- cgit v1.2.3