Plugin for repeating in operator-pending mode?

On occasion, I’ve run into scenarios where I wanted to do 2 separate operations on a selection/range. For example, copying 12 lines down and then commenting it out. To achieve this, you would do y12j followed by gc12j. You could also do V12jy and gvgc, but in my opinion that feels very unnatural, as it requires you to proactively think about your next action before you carry out your first one. My ideal sequence would be y12j followed by gc., which seems like a natural extension of the . functionality in normal mode. I’ve looked into plugins like vim-repeat and repmo.vim, but they are both geared towards normal mode.
Although Vim and Neovim do not provide access to the “last used text object” or “last motion”, I believe you could achieve something similar by using a catchall operator-pending mapping (somehow?) which uses feedkeys to forward keys to the buffer while also keeping track of the keys pressed for future . presses (as I’m typing this, the idea is already falling apart).
Is there a reasonable way to achieve this functionality? Since this is just a nicety, I completely understand if it’s not possible/not worth the effort to implement. Thanks

1 Like