I think you can use this for specific line
:10,15 norm! @d
If you want something like until line, you can use this instead
:.,15 norm! @d
Or a more visual way, by selecting the lines you want to change via Visual mode and then execute the command
You can also use 15: from normal mode to execute the macro for the next 15 lines
I think I'm almost there, maybe can use this as inspiration to make it work. I'm making use of kana/operator-user as in the suggested plugins.
The problem is entering insert mode during the repetition, so I've created a different operator to repeat using paste:
let g:loaded_operator_insert = 1
You can come up with something relatively simple, following and tinkering what vim has described in :h :map-operator:
As an example I came up with in about 15 minutes of experimenting:
nmap <silent> gi :set opfunc=InsertToTextObject<CR>g@
vmap <silent> gi :<C-U>call InsertToTextObject(visualmode(), 1)<CR>
nmap <silent> ...
Another way that also works across files is to use :h :vimgrep with g flag:
Without the 'g' flag each line is added only once.
With 'g' every match is added.
The workflow is:
Init your search pattern with /your pattern, record your macro in q.
Find all matching in your interested files:
vimgrep //g **/*.cpp **/*.h
Another possible answer is using vim-visual-multi.
First, select the pattern everywhere. To do so, use \\/ and then \\A to select all. And then \\@ with the macro register.
In your case, you could have done S" instead of using the macro after \\A.
Search for your pattern using /, then play your macro @@—you can record a new macro for this by doing
Assuming @a holds your original macro. Then @q will jump to the next occurrence and play your macro. (For this case, you may need qqn@anq.)
In this case, you also do