From 96eb03e9bd2b991f5c792f1fbd855a9ee189eeee Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Fri, 1 Oct 2010 16:58:51 +0200 Subject: vim_mode: Move movement W to new function. --- vim-mode/vim_mode.pl | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'vim-mode/vim_mode.pl') diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 5aa5274..44ebaae 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -683,12 +683,7 @@ sub cmd_movement_W { my ($count, $pos, $repeat) = @_; my $input = _input(); - while ($count-- > 0 and length($input) > $pos) { - if (substr($input, $pos + 1) !~ /\s+/) { - return cmd_movement_dollar(); - } - $pos += $+[0] + 1; - } + $pos = _beginning_of_WORD($input, $count, $pos); $pos = _fix_input_pos($pos, length $input); _input_pos($pos); } @@ -713,7 +708,20 @@ sub cmd_movement_E { _input_pos($pos); } } -# Go to the end of $count-th WORD, like vi's e. +# Go to beginning of $count-th WORD, like vi's W. +sub _beginning_of_WORD { + my ($input, $count, $pos) = @_; + + while ($count-- > 0 and length($input) > $pos) { + if (substr($input, $pos + 1) !~ /\s+/) { + return cmd_movement_dollar(); + } + $pos += $+[0] + 1; + } + + return $pos; +} +# Go to end of $count-th WORD, like vi's E. sub _end_of_WORD { my ($input, $count, $pos) = @_; -- cgit v1.2.3