nerdcommenter
nerdcommenter copied to clipboard
Add ability to specify register when yanking
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]yyand 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
- I'm not sure if this is possible. IMO it's not critical because it can be accomplished by remapping to the default maps:
- ❌
NERDComment({mode}, {type}, [{register}])- Specify register whentype=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.
- This works. It defaults to
- ✅ 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.
@alerque Could you take a look?