On Fr, 23 Mär 2018, Rich wrote:

> **Steps to Reproduce**
> 
> 1. `vim -Nu NONE`
> 2. `:set ve=insert`
> 3. `i123<CR>1<CR>12<Esc>`
> 4. `ggA`
> 5. `<C-G>jx`
> 6. `<C-G>jx`
> 
> **Expected results**
> 
>     123
>     1  x
>     12 x
> 
> **Observed results**
> 
>     123
>     1  x
>     1x2
> 
> The first `x` is in the correct column, but the second `x` is not where you'd 
> expect.
> 
> After performing the first downward `j` motion, the "insert start column" has 
> been set to the position of the end of the line *before* we move down into it 
> and enter text.
> 
> This sort of makes sense when we consider how `virtualedit` functions: it 
> allows you to move the cursor past the end of the line, but the position of 
> the end of the line isn't moved until *after* we enter the `x`, but it's not 
> really intuitive with how I think anyone would expect `<C-G>j` to work: I 
> would've expected that the "insert start column" should remain constant 
> throughout the current session of insert mode.

This happens, because the virtualedit setting is not taken into account. 
Attached is a patch with a test. 

Best,
Christian
-- 
Bemalung und Punktierung der Körper ist eine Rückkehr zur 
Tierheit.
                -- Goethe, Maximen und Reflektionen, Nr. 250

-- 
-- 
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/d/optout.
From 7b1021ca6f7f1e738113ae0d16e67356f64aa588 Mon Sep 17 00:00:00 2001
From: Christian Brabandt <[email protected]>
Date: Tue, 27 Mar 2018 18:51:04 +0200
Subject: [PATCH] Correctly move in insert mode when virtualedit is set

---
 src/charset.c                    |  7 ++++++-
 src/testdir/test_virtualedit.vim | 18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/src/charset.c b/src/charset.c
index 003949f0a..a3b21ca63 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1417,7 +1417,12 @@ getvcol_nolist(pos_T *posp)
     colnr_T	vcol;
 
     curwin->w_p_list = FALSE;
-    getvcol(curwin, posp, NULL, &vcol, NULL);
+#ifdef FEAT_VIRTUALEDIT
+    if (posp->coladd)
+	getvvcol(curwin, posp, NULL, &vcol, NULL);
+    else
+#endif
+	getvcol(curwin, posp, NULL, &vcol, NULL);
     curwin->w_p_list = list_save;
     return vcol;
 }
diff --git a/src/testdir/test_virtualedit.vim b/src/testdir/test_virtualedit.vim
index 2b8849f48..d49025237 100644
--- a/src/testdir/test_virtualedit.vim
+++ b/src/testdir/test_virtualedit.vim
@@ -38,6 +38,24 @@ func Test_paste_end_of_line()
   exe "normal! 2G$lllA\<C-O>:normal! \"agP\r"
   call assert_equal('123456', getline(2))
 
+  bwipe!
+  set virtualedit=
+endfunc
+
+func Test_edit_CTRL_G()
+  new
+  set virtualedit=insert
+  call setline(1, ['123', '1', '12'])
+  exe "normal! ggA\<c-g>jx\<c-g>jx"
+  call assert_equal(['123', '1  x', '12 x'], getline(1,'$'))
+
+  set virtualedit=all
+  %d_
+  call setline(1, ['1', '12'])
+  exe "normal! ggllix\<c-g>jx"
+  call assert_equal(['1 x', '12x'], getline(1,'$'))
+
+
   bwipe!
   set virtualedit=
 endfunc
-- 
2.16.1

Raspunde prin e-mail lui