aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Ruderich <simon@ruderich.org>2010-09-27 03:08:29 +0000
committerSimon Ruderich <simon@ruderich.org>2010-09-27 03:08:29 +0000
commit27d7acd387ebb1f36cb6756c1a5dc2e88c1ce903 (patch)
tree3f8e90ddbe1ddd03f33bc3377e87ae0f345c4d4f
parentvim_mode: Fix b and e not working between two words. (diff)
downloadirssi-scripts-27d7acd387ebb1f36cb6756c1a5dc2e88c1ce903.tar.gz
irssi-scripts-27d7acd387ebb1f36cb6756c1a5dc2e88c1ce903.zip
vim_mode: Add X.
-rw-r--r--vim-mode/vim_mode.pl18
1 files changed, 14 insertions, 4 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl
index f2ea5fc..742e7b8 100644
--- a/vim-mode/vim_mode.pl
+++ b/vim-mode/vim_mode.pl
@@ -187,6 +187,7 @@ my $movements
'$' => { func => \&cmd_movement_dollar },
# delete chars
'x' => { func => \&cmd_movement_x },
+ 'X' => { func => \&cmd_movement_X },
# insert mode
'i' => { func => \&cmd_movement_i },
'I' => { func => \&cmd_movement_I },
@@ -274,10 +275,10 @@ sub _get_pos_and_length {
$length *= -1;
}
- # w, x, h, l are the only movements which move one character after the
+ # w, x, X, h, l are the only movements which move one character after the
# deletion area (which is what we need), all other commands need one
# character more for correct deletion.
- if ($move ne 'w' and $move ne 'x' and $move ne 'h' and $move ne 'l') {
+ if ($move ne 'w' and $move ne 'x' and $move ne 'X' and $move ne 'h' and $move ne 'l') {
$length += 1;
}
@@ -555,6 +556,15 @@ sub cmd_movement_x {
cmd_operator_d($pos, $pos + $count, 'x');
}
+sub cmd_movement_X {
+ my ($count, $pos) = @_;
+
+ return if $pos == 0;
+
+ my $new = $pos - $count;
+ $new = 0 if $new < 0;
+ cmd_operator_d($pos, $new, 'X');
+}
sub cmd_movement_i {
_update_mode(M_INS);
@@ -929,8 +939,8 @@ sub handle_command {
# Store command, necessary for . But ignore movements and
# registers.
- if ($operator or $char eq 'x' or $char eq 'r' or
- $char eq 'p' or $char eq 'P' or
+ if ($operator or $char eq 'x' or $char eq 'X' or $char eq 'r'
+ or $char eq 'p' or $char eq 'P' or
$char eq 'C' or $char eq 'D' or
$char eq '~' or $char eq '"') {
$last->{char} = $char;