How to execute vim macro step by step (like debugging)?
Asked Answered
S

1

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?

Strictly answered 14/8, 2014 at 21:16 Comment(0)
E
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.

Extrovert answered 14/8, 2014 at 22:16 Comment(2)
This is the way I did it till now. But it's time-killing for long macros (e.g. restructure code).Strictly
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.Aground

© 2022 - 2024 — McMap. All rights reserved.