We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

4

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 :norm! @d EDIT! You can also use 15: from normal mode to execute the macro for the next 15 lines 15: norm!...


0

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: if exists('g:loaded_operator_insert') finish endif let g:loaded_operator_insert = 1 let s:...


2

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> ...


3

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 Reverse ...


1

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.


3

Search for your pattern using /, then play your macro @@—you can record a new macro for this by doing /pattern<CR>qqn@aq 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 :%substitute/pattern/"&"/g


Top 50 recent answers are included