On Do, 12 Sep 2013, shawn wilson wrote:
> Can vim be made to DWIM here? I did a quick search and found I'm not the
> only one who has run into this. For example:
> http://briancarper.net/blog/341/
>
> Just to re-explain what I want: when you visually select a block, you can
> change or insert and it will change the block but when you paste a single
> line buffer (I can see how this might get not be so simple for pasting
> multiple lines) it only changes the first line. The "fix" of using C+R in
> insert mode as was mentioned works, but the behavior isn't what I expect.
Try the attached patch.
regards,
Christian
--
Wir leben in einer Demokratie, und jeder kann frei entscheiden,
welche Sportart er machen möchte.
-- Michael Schumacher
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -9518,6 +9518,8 @@
/* cursor is at the end of the line or end of file, put
* forward. */
dir = FORWARD;
+ if (was_visual) /* reset by do_pending_operator */
+ VIsual_active = TRUE;
}
#endif
do_put(cap->oap->regname, dir, cap->count1, flags);
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -3776,25 +3776,43 @@
*/
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)
{
- 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() 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);
+ ptr += yanklen;
+ }
+ STRMOVE(ptr, oldp + col);
+ ml_replace(lnum, newp, FALSE);
+ /* Put 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
+ if (VIsual_active)
+ 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)))