Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sometimes when running a Vim macro the results aren't exactly as expected. Is there a way to "debug" this?

For example, it I could slow down macro execution and see what the input was for each step it would be very easy to see the issue.

share|improve this question
up vote 5 down vote accepted

What I do is edit the macro, either by putting and then yanking the register in a scratch buffer, or directly on the command line (:let @q = <C-r>=string(@q)<CR>). Unless I see the error, this usually means cutting of the tail of the macro to see where it goes wrong.

You could alternatively try to intersperse [N]gs (i.e. sleep N seconds) commands, if that helps you.

share|improve this answer
Thanks! I didn't know that you could view macro registers. It's :reg q to view the q register, for anyone else who's wondering. – Dean Jun 28 '13 at 20:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.