[vim/vim] Unexpected cursor position after using gp (#8899)

11 views
Skip to first unread message

naohiro ono

unread,
Sep 20, 2021, 1:05:47 PM9/20/21
to vim/vim, Subscribed

Describe the bug

Using gp to put the text of a register might move the cursor to an unexpected position when these conditions are met:

  • The text contains line break(s).
  • The register type is characterwise.
  • A count (> 1) is given to gp.

To Reproduce

  1. Run vim -Nu NONE.

  2. :source this script:

    call setreg('@', "foo\nbar", 'c')
    new
    let lines =<< trim END
      <---->
    END
    call setline(1, lines)
    normal! 1G2f-
    normal! 3gp

    The new window consists of these lines:

    <--foo
    barfoo
    barfoo
    bar-->
    

    This is expected.

    But the cursor is on the f of line 2, which is not expected.

Expected behavior

The cursor is on the first - of line 4. Because the help says gp leaves the cursor just after the new text:

							*gp*
["x]gp			Just like "p", but leave the cursor just after the new
			text.

Environment

  • Vim 8.2.3448
  • macOS 10.15.7
  • iTerm2


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

naohiro ono

unread,
Sep 20, 2021, 1:19:26 PM9/20/21
to vim/vim, Subscribed

It seems the position of '] mark is also wrong; it is placed on the r of line 2 (i.e. just before the cursor) in the example above. I would think it should be on the r of line 4.

Bram Moolenaar

unread,
Sep 22, 2021, 10:38:00 AM9/22/21
to vim/vim, Subscribed

Closed #8899 via 23003e5.

naohiro ono

unread,
Sep 23, 2021, 12:18:38 AM9/23/21
to vim/vim, Subscribed

Thank you!

Reply all
Reply to author
Forward
0 new messages