Mercurial > vim
diff src/ops.c @ 5365:22dfcd1494e4 v7.4.034
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)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 22 Sep 2013 15:23:44 +0200 |
parents | 46cf49cc9289 |
children | 408f2a1a953f |
line wrap: on
line diff
--- a/src/ops.c +++ b/src/ops.c @@ -3776,25 +3776,42 @@ do_put(regname, dir, count, flags) */ if (y_type == MCHAR && y_size == 1) { - totlen = count * yanklen; - if (totlen) - { - 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) + do { + totlen = count * yanklen; + if (totlen > 0) { - mch_memmove(ptr, y_array[0], (size_t)yanklen); - ptr += yanklen; + oldp = ml_get(lnum); + 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); - ml_replace(lnum, newp, FALSE); - /* Put cursor on last putted char. */ - curwin->w_cursor.col += (colnr_T)(totlen - 1); - } +#ifdef FEAT_VISUAL + if (VIsual_active) + lnum++; +#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; /* For "CTRL-O p" in Insert mode, put cursor after last char */ if (totlen && (restart_edit != 0 || (flags & PUT_CURSEND)))