22

I recorded a macro to a register and started it with too many repetitions. It takes way to much time to complete each macro.

How do I cancel/stop Vim executing macro? Is there a way by doing it without killing editor process?

Here are the steps I followed:

  1. Recorded macro to register 1
  2. I run it 1000 times: 1000@1
  3. Now waiting about 6 seconds to complete each macro.
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
BlueNile
  • 391
  • 1
  • 5
  • 12
  • 1
    You are supposed to record macros in registers a to z. Registers 1 to 9 are reserved for yanking and deleting and updated each time you do a yank or delete, that's a probable cause for the slowness that you experience. – romainl Sep 11 '13 at 20:47
  • 1
    Thanks for the comment. I will switch to letters. On the note of performance I had to do following commands to make it run fast: syntax off set undolevels=0 – BlueNile Sep 11 '13 at 21:24

1 Answers1

38

C-c works

Also, you can let it break on error. (which, I think, is the default). I sometimes temporarily do

 :se nowrapscan

to avoid "infinitely" looping over my buffer


Also, to speed up macro execution, make it silent:

:silent! norm 1000@q
sehe
  • 374,641
  • 47
  • 450
  • 633
  • Ctrl-C didn't work on Vim 7.4 for Windows. I've upgraded to Vim 8.0 and it works there. – mwardm Apr 11 '17 at 08:33
  • @mwardm Vim (used to) has "Windows mode" default config (I hate it). On Windows, ^C and ^V got mapped to... copy/paste. I think ^Q replaced ^C but I'm not sure. I usually drop any `behave mswin` and related cruft from the vimrc – sehe Apr 11 '17 at 08:34
  • @sehe I think I'd tried ctrl-Q for some reason but unfortunately I already have that as my systemwide hotkey for SlickRun :-) As you implied, it could well be that the upgrade has resulted in a change to my config that has allowed things to work. – mwardm Apr 11 '17 at 15:11