On Sa, 28 Sep 2013, Bram Moolenaar wrote:

> Can't you just use the example you gave above?  No CTRL-O there.

Here is an updated patch, including a test. Using :exe one can use the 
cursor keys just like normal, while if you use Cursor Right literally in 
the test file, this will look like ^[OC, which will then be interpreted 
like <esc>, "O" and finally "C" when running the test.

regards,
Christian
-- 
Fast jede Frau wäre gern treu. Schwierig ist es bloß, den Mann zu
finden, dem man treu sein kann.
                -- Marlene Dietrich

-- 
-- 
You received this message from the "vim_dev" 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_dev" 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/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -2617,6 +2617,29 @@
     {
 	struct block_def	bd2;
 
+	/* Probably the user moved the cursor before inserting something,
+	 * so try to adjust the block */
+	if (oap->start.lnum == curbuf->b_op_start.lnum)
+	{
+	    if (oap->op_type == OP_INSERT &&
+		oap->start.col != curbuf->b_op_start.col)
+	    {
+		oap->start.col = curbuf->b_op_start.col;
+		pre_textlen -= getviscol2(oap->start.col, oap->start.coladd) - oap->start_vcol;
+		oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
+	    }
+	    else if (oap->op_type == OP_APPEND &&
+		oap->end.col >= curbuf->b_op_start.col)
+	    {
+		oap->start.col  = curbuf->b_op_start.col;
+		/* reset pre_textlen to the value of OP_INSERT */
+		pre_textlen     += bd.textlen;
+		pre_textlen     -= getviscol2(oap->start.col, oap->start.coladd) - oap->start_vcol;
+		oap->start_vcol = getviscol2(oap->start.col, oap->start.coladd);
+		oap->op_type = OP_INSERT;
+	    }
+	}
+
 	/*
 	 * Spaces and tabs in the indent may have changed to other spaces and
 	 * tabs.  Get the starting column again and correct the length.
diff --git a/src/testdir/test39.in b/src/testdir/test39.in
--- a/src/testdir/test39.in
+++ b/src/testdir/test39.in
@@ -19,6 +19,10 @@
 :" Test block-change
 G$khhhhhkkcmno
 :$-4,$w! test.out
+:" Test block-insert using cursor keys for movement
+/^aaaa/
+:exe ":norm! l\<C-V>jjjlllI\<Right>\<Right>  \<Esc>"
+:/^aa/,/^$/w >> test.out
 :" gUe must uppercase a whole word, also when ß changes to SS
 Gothe youtußeuu endYpk0wgUe
 :" gUfx must uppercase until x, inclusive.
@@ -36,6 +40,11 @@
 :qa!
 ENDTEST
 
+aaaaaa
+bbbbbb
+cccccc
+dddddd
+
 abcdefghijklm
 abcdefghijklm
 abcdefghijklm
diff --git a/src/testdir/test39.ok b/src/testdir/test39.ok
--- a/src/testdir/test39.ok
+++ b/src/testdir/test39.ok
@@ -3,6 +3,11 @@
 axyzqqqqef mno        ghijklm
 axyzqqqqefgmnoklm
 abcdqqqqijklm
+aaa  aaa
+bbb  bbb
+ccc  ccc
+ddd  ddd
+
 the YOUTUSSEUU end
 - yOUSSTUSSEXu -
 THE YOUTUSSEUU END

Raspunde prin e-mail lui