0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

updated for version 7.4.034

Problem:    Using "p" in Visual block mode only changes the first line.
Solution:   Repeat the put in all text in the block. (Christian Brabandt)
This commit is contained in:
Bram Moolenaar 2013-09-22 15:23:44 +02:00
parent 6848c8b561
commit ec11aef914
6 changed files with 55 additions and 19 deletions

View File

@ -1069,6 +1069,11 @@ another register. E.g., yank the text to copy, Visually select the text to
replace and use "0p . You can repeat this as many times as you like, the replace and use "0p . You can repeat this as many times as you like, the
unnamed register will be changed each time. unnamed register will be changed each time.
When you use a blockwise Visual mode command and yank only a single line into
a register, a paste on a visual selected area will paste that single line on
each of the selected lines (thus replacing the blockwise selected region by a
block of the pasted line).
*blockwise-register* *blockwise-register*
If you use a blockwise Visual mode command to get the text into the register, If you use a blockwise Visual mode command to get the text into the register,
the block of text will be inserted before ("P") or after ("p") the cursor the block of text will be inserted before ("P") or after ("p") the cursor

View File

@ -9518,6 +9518,8 @@ nv_put(cap)
/* cursor is at the end of the line or end of file, put /* cursor is at the end of the line or end of file, put
* forward. */ * forward. */
dir = FORWARD; dir = FORWARD;
/* May have been reset in do_put(). */
VIsual_active = TRUE;
} }
#endif #endif
do_put(cap->oap->regname, dir, cap->count1, flags); do_put(cap->oap->regname, dir, cap->count1, flags);

View File

@ -3776,25 +3776,42 @@ do_put(regname, dir, count, flags)
*/ */
if (y_type == MCHAR && y_size == 1) if (y_type == MCHAR && y_size == 1)
{ {
totlen = count * yanklen; do {
if (totlen) totlen = count * yanklen;
{ if (totlen > 0)
oldp = ml_get(lnum);
newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1));
if (newp == NULL)
goto end; /* alloc() will give error message */
mch_memmove(newp, oldp, (size_t)col);
ptr = newp + col;
for (i = 0; i < count; ++i)
{ {
mch_memmove(ptr, y_array[0], (size_t)yanklen); oldp = ml_get(lnum);
ptr += yanklen; newp = alloc_check((unsigned)(STRLEN(oldp) + totlen + 1));
if (newp == NULL)
goto end; /* alloc() gave an error message */
mch_memmove(newp, oldp, (size_t)col);
ptr = newp + col;
for (i = 0; i < count; ++i)
{
mch_memmove(ptr, y_array[0], (size_t)yanklen);
ptr += yanklen;
}
STRMOVE(ptr, oldp + col);
ml_replace(lnum, newp, FALSE);
/* Place cursor on last putted char. */
if (lnum == curwin->w_cursor.lnum)
curwin->w_cursor.col += (colnr_T)(totlen - 1);
} }
STRMOVE(ptr, oldp + col); #ifdef FEAT_VISUAL
ml_replace(lnum, newp, FALSE); if (VIsual_active)
/* Put cursor on last putted char. */ lnum++;
curwin->w_cursor.col += (colnr_T)(totlen - 1); #endif
} } while (
#ifdef FEAT_VISUAL
VIsual_active && lnum <= curbuf->b_visual.vi_end.lnum
#else
FALSE /* stop after 1 paste */
#endif
);
#ifdef FEAT_VISUAL
VIsual_active = FALSE;
#endif
curbuf->b_op_end = curwin->w_cursor; curbuf->b_op_end = curwin->w_cursor;
/* For "CTRL-O p" in Insert mode, put cursor after last char */ /* For "CTRL-O p" in Insert mode, put cursor after last char */
if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND))) if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))

View File

@ -9,11 +9,17 @@ G0"ay$k@au
@auY:quit! @auY:quit!
GP GP
/start here$ /start here$
jjlld "by$jjlld
:/here$/,$-1w! test.out /456$
jj"bP
:/56$/,$-1w! test.out
:qa! :qa!
ENDTEST ENDTEST
123456
234567
345678
test text test tex start here test text test tex start here
some text some text
test text test text

View File

@ -1,3 +1,7 @@
123start here56
234start here67
345start here78
test text test tex rt here test text test tex rt here
somext somext
tesext tesext

View File

@ -738,6 +738,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
34,
/**/ /**/
33, 33,
/**/ /**/