7

Sometimes when my vim macros become too long, there are small mistakes. But without being able to execute the macro step by step, it's really hard to find the problem.

Is there a possibility to step through vim macros or debug them in any way?

miu
  • 1,234
  • 2
  • 18
  • 34

1 Answers1

1

If you want to look at the contents of a macro you can use :reg a where a is the register you stored your macro in.

Then you can paste the contents of the register with "ap where a is the register name. Once you have done this you can change the line to suit your liking. Finally you can bring turn it back into a macro by using "ayy where a is the register name.

Zach
  • 4,652
  • 18
  • 22
  • 2
    This is the way I did it till now. But it's time-killing for long macros (e.g. restructure code). – miu Aug 14 '14 at 23:39
  • 4
    Turn it in to a function if you use the macro a lot. Most macro commands are translatable relatively easily to function commands then modification and step by step running become much easier. The pain of converting to a function is only worth it if you use it a lot. – Steve Aug 15 '14 at 01:06