Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 4 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
add comment

Your Answer

 
discard

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.