I'm saving a very simple vim macro to a key: qa$pjq and then executing it 40000 times with 40000@a. This is very slow. I must be doing something wrong, because while it does work it takes something like 60-90 seconds. Is this as fast as vim goes? Are there some settings that can accelerate this? Is there a mixture of plugins that make macro execution slow?
I'm using a Mac and using MacVim. It is a plain text file, it really doesn't get any simpler than this.
It doesn't take long to paste 40,000 lines, but if you've got the screen constantly updating as you often do in a macro that slows things down.
First, a question about what your macro is supposed to be doing. If it's simply pasting contents of default register, then proper macro definition is just qapjq
. There is no need to position the cursor in a specific spot on previous line. [EDIT: sorry, I was assuming you were doing linewise paste, positioning is needed if you're pasting character-wise register at end of line. . .. ]
Second, you can speed up your current macro by setting lazyredraw (:set lazyredraw
), so screen doesn't update as it goes. Probably won't speed things up a whole lot, keyboard macros like this aren't like direct processing of the buffer.
Third, here's another method that should take about a second:
.,+40000g/.*/normal! $p
This is normal. As Herbert Sitz wrote, updating the screen is slow.
You might want to just run a substitution command: :.,+40000s/.*/&<c-r>"
.
.,+40000
is a range including the current line and the 40000 following.*
in the pattern matches a whole line&
in the string is the line that was matched<c-r>"
pastes the contents of the unnamed registerI would recommend to start a blank vim with 'vim -u NONE '. Often plugins are slowing down things. You will see that it works much faster this way. Then you need to find out what plugin causes this slowdown. See also How to see which plugins are making Vim slow?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With