Skip to content

Add ability to specify register when yanking #544

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 3 commits into
base: master
Choose a base branch
from

Conversation

jacktose
Copy link

@jacktose jacktose commented May 6, 2025

NERDCommenterYank (\cy) yanks to the default unnamed register ". Like all other yanking, this is a good default, this gives the user an option to choose another register.
One use case is creating a “comment and duplicate” function/mapping without clobbering the default register, as discussed in #435.
Closes #543

Goals

  • ["x][count]\cy - Support standard register specification for NERDCommenterYank mapping, as with ["x]yy and friends.
  • ["x]<plug>NERDCommenterYank, <plug>NERDCommenterYank({register}), or similar way to specify a register when invoking this way (e.g. in a user-defined function or mapping).
    • I'm not sure if this is possible. IMO it's not critical because it can be accomplished by remapping to the default maps: nmap \abc "x\cy
  • NERDComment({mode}, {type}, [{register}]) - Specify register when type=Yank.
    • I'm very reluctant to mess with the main function signature.
  • let g:NERDDefaultRegister = x - Set default register used by NERDCommenterYank.
    • This works. It defaults to " (so no behavior change by default) and is overridden when specifying a register with "x.
  • ✅ Update documentation

Validation

This works for me in vim 9.1.
I'm brand new to vim help files, and not much better at vimscript, so additional eyes and feedback are welcome.

@jacktose jacktose marked this pull request as ready for review May 6, 2025 23:35
@jacktose
Copy link
Author

jacktose commented Jun 6, 2025

@alerque Could you take a look?

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.

[Feature request] ability to specify register when yanking
1 participant