{
if (flags & PUT_LINE_SPLIT)
{
+ char_u *p;
+
/* "p" or "P" in Visual mode: split the lines to put the text in
* between. */
if (u_save_cursor() == FAIL)
goto end;
- ptr = vim_strsave(ml_get_cursor());
+ p = ml_get_cursor();
+ if (dir == FORWARD && *p != NUL)
+ mb_ptr_adv(p);
+ ptr = vim_strsave(p);
if (ptr == NULL)
goto end;
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, FALSE);
vim_free(ptr);
- ptr = vim_strnsave(ml_get_curline(), curwin->w_cursor.col);
+ oldp = ml_get_curline();
+ p = oldp + curwin->w_cursor.col;
+ if (dir == FORWARD && *p != NUL)
+ mb_ptr_adv(p);
+ ptr = vim_strnsave(oldp, p - oldp);
if (ptr == NULL)
goto end;
ml_replace(curwin->w_cursor.lnum, ptr, FALSE);
:$put ='c'
kgH<Down><Del>
:$put ='---'
+:
+:$put =''
+:$put ='v_p: replace last character with line register at middle line'
+:$put ='aaa'
+:$put ='bbb'
+:$put ='ccc'
+:-2yank
+k$vp
+:$put ='---'
+:
+:$put =''
+:$put ='v_p: replace last character with line register at middle line selecting newline'
+:$put ='aaa'
+:$put ='bbb'
+:$put ='ccc'
+:-2yank
+k$v$p
+:$put ='---'
+:
+:$put =''
+:$put ='v_p: replace last character with line register at last line'
+:$put ='aaa'
+:$put ='bbb'
+:$put ='ccc'
+:-2yank
+$vp
+:$put ='---'
+:
+:$put =''
+:$put ='v_p: replace last character with line register at last line selecting newline'
+:$put ='aaa'
+:$put ='bbb'
+:$put ='ccc'
+:-2yank
+$v$p
+:$put ='---'
:/^start:/+2,$w! test.out
:q!
ENDTEST
linewise select mode: delete last two line
a
---
+
+v_p: replace last character with line register at middle line
+aaa
+bb
+aaa
+
+ccc
+---
+
+v_p: replace last character with line register at middle line selecting newline
+aaa
+bb
+aaa
+ccc
+---
+
+v_p: replace last character with line register at last line
+aaa
+bbb
+cc
+aaa
+
+---
+
+v_p: replace last character with line register at last line selecting newline
+aaa
+bbb
+cc
+aaa
+
+---