From 5cbd1e07ee5a7d75019512150d34db98788056e7 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Wed, 29 Sep 2010 03:47:08 +0200 Subject: vim_mode: Fix cursor position to work like Vim. --- vim-mode/vim_mode.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'vim-mode') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 8dfa35d..786921c 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -1370,6 +1370,17 @@ sub _stop() { sub _update_mode { my ($new_mode) = @_; + + # In insert mode we are "between" characters, in command mode "on top" of + # keys. When leaving insert mode we have to move on key left to accomplish + # that. + if ($mode == M_INS and $new_mode == M_CMD) { + my $pos = _input_pos(); + if ($pos != 0) { + _input_pos($pos - 1); + } + } + $mode = $new_mode; if ($mode == M_INS) { $history_index = undef; -- cgit v1.2.3