Index | Thread | Search

From:
Christian Schulte <cs@schulte.it>
Subject:
Re: Another vi(1) past improvement (Rational)
To:
Walter Alejandro Iglesias <wai@roquesor.com>
Cc:
tech@openbsd.org
Date:
Thu, 4 Sep 2025 19:48:03 +0200

Download raw body.

Thread
 
> Let me add (I shouldn't since I have explained this). Currently the
> command 'P' doesn't suffer the issue, just 'p'. ;-)

This better be discussed misc@. The 'p' command is consistent to itself
here. The motion that command performs may appear unintuitive. vim
behaves the same way you describe being an issue. So there is no (easy)
way to change that without becoming incompatible with other vi
implementations. Example:

1
2
^3
Cursor positioned here manually after 3yy at line 1. Typing 'p' yields.

1
2
3
^1
Cursor moved here after 'p' (line 4, col 0).
2
3

Repeat but instead of just one 'p', add a count.

1
2
^3
Again. Cursor positioned manually here after 3yy at line 1. Typing '4p'
yields.

1
2
3
^1
Cursor consistently positioned at the same position it got positioned
with just '1p' (line 4, col 0). Buffer got appended correctly.
2
3
1
2
3
1
2
3
1
2
3

What may appear confusing is that typing 'pppp' instead of '4p' yields
a different result. In all three cases ('p', '4p', 'pppp') the motion
part of the command is the same and that is consistent with the normal
append operation. Example:

1
2
^3

Same as above. Simulate a line based one line append operation by
typing 'a' followed by a newline (return).

1
2
3
^ Cursor at the same position (line 4, col 0).

As you are way more familiar with the code, is that inconsistent to 
the count times action then motion pattern?

Index: usr.bin/vi/docs/USD.doc/vi.man/vi.1
===================================================================
RCS file: /cvs/src/usr.bin/vi/docs/USD.doc/vi.man/vi.1,v
diff -u -p -u -r1.85 vi.1
--- usr.bin/vi/docs/USD.doc/vi.man/vi.1	24 Apr 2024 15:15:40 -0000	1.85
+++ usr.bin/vi/docs/USD.doc/vi.man/vi.1	4 Sep 2025 16:54:53 -0000
@@ -1393,7 +1393,7 @@ Append text from
 .Ar buffer .
 Text is appended after the current column if
 .Ar buffer
-is character oriented, or the after current line otherwise.
+is character oriented, or after the current line otherwise.
 .Pp
 .It Xo
 .Op Ar count