Skip to content

Make counted p more usable #150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Make counted p more usable #150

wants to merge 2 commits into from

Conversation

lichray
Copy link
Owner

@lichray lichray commented Aug 18, 2025

Contributed by Walter Alejandro Iglesias [email protected]

An implementation detail of p with a count made it not as usable as P. Users have to switch to P with a count to get sensible content. The patch solves the issue by factoring the cursor placement out of p/P with a count. After the change, p also collects content without interleaving.

To illustrate how bizarre the current behavior is, consider this example:

First,
v Put the cursor here, yank "Hello" with 'ye'
    v Move the cursor to 'o' and paste with '2p'
Hello
v And then, open a new line and paste with '2p' again

After the first operation, you will get

HelloHHelloello
     ^ where the cursor lands on the first 'H'

After the second operation, you will get

HHelloello
 ^ but this time the cursor lands on the second 'H'

This means if you use 3p instead of 2p to repeat the example, the content to paste with the two operations (with or without starting on an empty line) will diverge. You end up with

HelloHHelloHelloello
     ^ and
HHHelloelloello
 ^ respectively.

This also affects line-based p with a count.

The proposed change produces

HelloHelloHelloHello
     ^ and
HelloHelloHello
^

Closes: #146

@lichray lichray requested review from bentley and leres August 18, 2025 05:36
@lichray lichray changed the title Less useless numbered p Make counted p more usable Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Counterintuitive outcome of 'p' with numeral prefix
1 participant