aboutsummaryrefslogtreecommitdiffstats
path: root/vim-mode/vim_mode.pl
diff options
context:
space:
mode:
Diffstat (limited to 'vim-mode/vim_mode.pl')
-rw-r--r--vim-mode/vim_mode.pl8
1 files changed, 7 insertions, 1 deletions
diff --git a/vim-mode/vim_mode.pl b/vim-mode/vim_mode.pl
index e372050..39752fc 100644
--- a/vim-mode/vim_mode.pl
+++ b/vim-mode/vim_mode.pl
@@ -430,7 +430,13 @@ sub _paste_at_position {
my $string = $registers->{'"'} x $count;
my $input = _input();
- substr($input, $pos, 0) = $string;
+ # Check if we are not at the end of the line to prevent substr outside of
+ # string error.
+ if (length $input > $pos) {
+ substr($input, $pos, 0) = $string;
+ } else {
+ $input .= $string;
+ }
_input($input);
_input_pos($pos - 1 + length $string);