Editing vim macros

What happened?

I often fail writing a proper makro. Often it kinda works, but I forgot a little thing. In vim I edited the marko then by yanking it into the current buffer, do my changes manually, then killing it back into the register.
It Doom that does not work. I can not past a register that contains the makro and itstead it says “Wrong type argument: characterp, right” in the minibuffer. I tried to open the registers with SPC i r and got the content of the registers from there by doing a simple yy on the line. When I did my changes I can kill the line back into the register, but when I try to execute the makro with @j (j happens to be the registers) it says “After 0 kbd macro iterations: Quit”

I am not asking for this behavior to be exactly the same like in vim. I would be happy if I just had any way to edit the macros, doesn’t have to be vims way.

What did you expect to happen?

Macros can be yanked from evil registers like any other text, changed and kill into the register and then used as a makro again.

Steps to reproduce

  1. define a macro with q j <macro commands here>
  2. try to yank the macro into a buffer with "jp

System information

Loading data dump...

See this Evil comment.

Evil uses Emacs’ own not-only-keyboard macro system (it wraps kmacro-start-macro/execute-kbd-macro functions), which can capture a bunch of input events represented differently. When putting a macro from register or executing yanked text as a macro (or e.g. doing norm ex command), Evil only recognizes a small subset of input events (namely, chars and escape key).

any way to edit the macros

You can use kmacro-edit-macro command to edit the last macro captured by Evil in Emacs’ built-in editor. It’s more capable, but doesn’t do all the input events as well.

1 Like

Ok I see. Thank you. So those makros become a function I can call in Lisp once I name theme. Is there a way to load them back into the editor and change them, once I named them?

// that would be edit-named-keyboard-macro I figure…

Create an interactive function to run macro using kmacro-name-last-macro command, then dump its definition with insert-kbd-macro. Drop it into your config.el. These generated functions aren’t perfect either, however.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.