diff options
| author | Simon Ruderich <simon@ruderich.org> | 2010-10-01 14:50:23 +0000 | 
|---|---|---|
| committer | Simon Ruderich <simon@ruderich.org> | 2010-10-01 15:10:57 +0000 | 
| commit | 47b760256e13fbb6548e2aaeacfd152ed31b455b (patch) | |
| tree | a7c848ddc0aaa15a5a74fade2e72924e4370b88c | |
| parent | vim_mode: " is not repeatable. (diff) | |
| download | irssi-scripts-47b760256e13fbb6548e2aaeacfd152ed31b455b.tar.gz irssi-scripts-47b760256e13fbb6548e2aaeacfd152ed31b455b.zip | |
vim_mode: Move movement w to new function.
| -rw-r--r-- | vim-mode/vim_mode.pl | 33 | 
1 files changed, 20 insertions, 13 deletions
| diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 52129c0..5aa5274 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -600,19 +600,7 @@ sub cmd_movement_w {      my ($count, $pos, $repeat) = @_;      my $input = _input(); -    while ($count-- > 0) { -        # Go to end of next word/non-word. -        if (substr($input, $pos) =~ /^$word+/ or -            substr($input, $pos) =~ /^$non_word+/) { -            $pos += $+[0]; -        } -        # And skip over any whitespace if necessary. This also happens when -        # we're inside whitespace. -        if (substr($input, $pos) =~ /^\s+/) { -            $pos += $+[0]; -        } -    } - +    $pos = _beginning_of_word($input, $count, $pos);      $pos = _fix_input_pos($pos, length $input);      _input_pos($pos);  } @@ -636,6 +624,25 @@ sub cmd_movement_e {      $pos = _fix_input_pos($pos, length $input);      _input_pos($pos);  } +# Go to the beginning of $count-th word, like vi's w. +sub _beginning_of_word { +    my ($input, $count, $pos) = @_; + +    while ($count-- > 0) { +        # Go to end of next word/non-word. +        if (substr($input, $pos) =~ /^$word+/ or +            substr($input, $pos) =~ /^$non_word+/) { +            $pos += $+[0]; +        } +        # And skip over any whitespace if necessary. This also happens when +        # we're inside whitespace. +        if (substr($input, $pos) =~ /^\s+/) { +            $pos += $+[0]; +        } +    } + +    return $pos; +}  # Go to the end of $count-th word, like vi's e.  sub _end_of_word {      my ($input, $count, $pos) = @_; | 
