I am trying to implement the following: duplicate the currently selected region or a line (if there is no selection) and comment out the original region with the help of comment-or-uncomment-region-or-line
.
I figured I could use kill-region
followed by yank
but then my original selection is lost, so I can't comment. If on the other hand I comment first I will get both copies of my region commented out.
The other idea I have (which I think is better because I use evil-mode) is to use evil-yank
and then evil-visual-restore
to restore the selection so that I can comment it out. But I can't figure what arguments to pass to evil-yank
to specify the selected region.
What am I missing here?