diff options
author | Simon Ruderich <simon@ruderich.org> | 2010-09-26 21:30:57 +0000 |
---|---|---|
committer | Simon Ruderich <simon@ruderich.org> | 2010-09-26 21:30:57 +0000 |
commit | 940a76ef44cf041bb815b3ade57b67bf78f9b64a (patch) | |
tree | b3a077fe4423fa34e33d5c63924584cb544b57cf /vim-mode | |
parent | vim_mode: Document S. (diff) | |
download | irssi-scripts-940a76ef44cf041bb815b3ade57b67bf78f9b64a.tar.gz irssi-scripts-940a76ef44cf041bb815b3ade57b67bf78f9b64a.zip |
vim_mode: Add ^ and fix I to use it.
Diffstat (limited to 'vim-mode')
-rw-r--r-- | vim-mode/vim_mode.pl | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl index 12bff22..a91f081 100644 --- a/vim-mode/vim_mode.pl +++ b/vim-mode/vim_mode.pl @@ -172,6 +172,7 @@ my $movements 'E' => { func => \&cmd_movement_E }, # line movement '0' => { func => \&cmd_movement_0 }, + '^' => { func => \&cmd_movement_caret }, '$' => { func => \&cmd_movement_dollar }, # delete chars 'x' => { func => \&cmd_movement_x }, @@ -457,6 +458,21 @@ sub _end_of_WORD { sub cmd_movement_0 { _input_pos(0); } +sub cmd_movement_caret { + my $input = _input(); + my $pos; + # No whitespace at all. + if ($input !~ m/^\s/) { + $pos = 0; + # Some non-whitesapece, go to first one. + } elsif ($input =~ m/[^\s]/) { + $pos = $-[0]; + # Only whitespace, go to the end. + } else { + $pos = _input_len(); + } + _input_pos($pos); +} sub cmd_movement_dollar { _input_pos(_input_len()); } @@ -471,7 +487,7 @@ sub cmd_movement_i { _update_mode(M_INS); } sub cmd_movement_I { - cmd_movement_0(); + cmd_movement_caret(); _update_mode(M_INS); } sub cmd_movement_a { |