Skip to content

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