diff options
author | Simon Ruderich <simon@ruderich.org> | 2010-10-01 14:58:51 +0000 |
---|---|---|
committer | Simon Ruderich <simon@ruderich.org> | 2010-10-01 15:10:59 +0000 |
commit | 96eb03e9bd2b991f5c792f1fbd855a9ee189eeee (patch) | |
tree | 371a92b5d5304be8d8a6b24efe748052a69777a3 /vim-mode | |
parent | vim_mode: Move movement w to new function. (diff) | |
download | irssi-scripts-96eb03e9bd2b991f5c792f1fbd855a9ee189eeee.tar.gz irssi-scripts-96eb03e9bd2b991f5c792f1fbd855a9ee189eeee.zip |
vim_mode: Move movement W to new function.
Diffstat (limited to 'vim-mode')
-rw-r--r-- | vim-mode/vim_mode.pl | 22 |
1 files changed, 15 insertions, 7 deletions
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) = @_; |