Skip to content

feat(vim): add p/P paste for last delete - #16

Merged
aakashrajput merged 1 commit into
KlaatAI:mainfrom
Devil1716:fix/6-vim-paste
Jul 18, 2026
Merged

feat(vim): add p/P paste for last delete#16
aakashrajput merged 1 commit into
KlaatAI:mainfrom
Devil1716:fix/6-vim-paste

Conversation

@Devil1716

Copy link
Copy Markdown
Contributor

Summary

  • Vim NORMAL mode keeps the last deleted text from x / dd / D (and dw / d$) in one unnamed register.
  • p pastes after the cursor; P pastes before.
  • Help / /vimmode on copy updated.
  • Fixes Vim mode: add p/P paste after dd/x delete #6

Test plan

  • /vimmode on, type a line, Esc, dd, p → line restored
  • x then p restores the deleted character after the cursor
  • P inserts before the cursor
  • No named registers / yy required

Track text removed by x/dd/D (and dw/d$) in a single yank slot and re-insert it with p (after cursor) or P (before) (KlaatAI#6).

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

Copy link
Copy Markdown
Contributor

🤖 KlaatAI Review Bot (powered by Klaatu, advisory only — a maintainer makes the real call)

Issue match
Fully addresses #6. Implements the unnamed vimYank register, captures deletions for x, dd, D, dw, and d$, and adds p/P handlers. Help text is also correctly updated.

Test coverage
No automated tests were added. While the PR body includes a manual test plan, there are no unit tests verifying the yankDeleted diffing logic (e.g., prefix, suffix, and middle-of-string deletions) or the p/P cursor positioning.

Correctness concerns
The yankDeleted helper assumes the deletion is a single contiguous block, slicing the removed text by finding the first diverging index. This works for the implemented motions. However, if field.paste(vimYank) receives a string containing a newline (e.g., if dd captures one despite singleLine: true), it could corrupt the single-line input field. Additionally, p uses field.handleKey(mk("right")); if the cursor is at the end of the line, right is a no-op, correctly resulting in an append that matches standard Vim behavior.

Verdict
Ready to merge as-is, though I would flag to a human reviewer whether the manual test plan is sufficient or if automated tests for the yankDeleted string manipulation are required.

This is an automated review to help triage faster, not a gate. Nothing here blocks merging.

@aakashrajput

Copy link
Copy Markdown
Member

@Devil1716
Thanks a lot for your contribution! 🎉

Really appreciate you taking the time to improve KlaatCode. Your contribution helps make the project better for everyone.

If you haven't already, we'd love it if you could ⭐ star the repository and follow @KlaatAI on GitHub to stay updated with new features and releases.

Feel free to keep using KlaatAI for your projects, and don't hesitate to open more issues, suggest ideas, or submit future PRs—we're always happy to have contributors like you in the community.

Looking forward to seeing your next contribution. Happy coding! 🚀

@aakashrajput
aakashrajput merged commit b0933fd into KlaatAI:main Jul 18, 2026
1 check passed
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.

Vim mode: add p/P paste after dd/x delete

2 participants