Do macro commands deserve to be on 'q' key?

Kakoune has the following macro normal commands:

  • Q start recording macro
  • q play macro

In my workflow, I observe that I hardly ever use macros thanks to multi-selections. Nevertheless they waste by default a place of choice on the keyboard! This is mainly explained by the vim lineage where the q key is also used to replay macro.

Of course, every user is free to remap them somewhere else and use the q to perform whatever actions they need.

Do you remap the q to something else? Do you think macro commands should be move to another key by default?

1 Like

It might be due to MY vim heritage, but I use macros relatively often in Kakoune. Might be because my multi-selection chops aren’t good enough yet. Also, I kinda like that it rots because I use alt-q to switch panes in tmux. ducks

I also never use macros. In the rare cases that multi-selections don’t cut it, I tend to just type out the exec sequence, I find that less error-prone than recording a macro.

One problem with remapping q/Q is that you cannot do :exec Q to record a macro, probably due to some context cleanup. I guess I should report it.

1 Like

I think macro earned it’s place on keyboard because it’s pretty powerful command. I don’t use it as often as in Vim. I see two common use-cases in my workflow:

  • irregular code that is hard to select all at once. I record rough edit and then tweak manually case by case. Example: converting function signatures from C header to Crystal bindings.
  • working with incremental changes. Example - writing markdown document. If I paste a lot of URLs, I record macro that converts URL under cursor to markdown link. I could do this at the end but have to write link description manually anyway.
  • there is also golfing… :laughing:
1 Like

actually in Vim q was used to record a macro on any key on the keyboard, e.g. qq records macro on the q key, and qw records macro on the w key.

To play recorded macro one need to use the @ key, followed by the macro key, like @q, or @w. You also can repeat last macro with @@.

Kakoune on the other hand forces user to use the q key to play the macro, and we do not choose which macro to play, as we didn’t choose where to record it.

But we can use registers for that, so what was in Vim as:
record macro on w: qw, then play manually 3 times: @w@@@@
in Kakoune is:
record macro on w: "wQ, then play manually 3 times: "wq"wq"wq

I don’t use macros very often, especially on non default register, but in the example above we need to press 4 more keys compared to Vim.

Indeed, this is a place where I really wish repeat “did what I want” – which I can never seem to get it to do. Either version!

you could record a macro that calls another macro… But that’s stupid :smiley:

I mean, mashing q (or count q) if on default is easy enough. I use macro’s semi-regularly do to stuff to a list of files I have open… “go into file, do a thing, leave file back to list, go to next line” (repeat)

I don’t use macros that often, but one thing they’re indispensable for is iterative operations.
Numbered lists being an example.

Qxypl<a-i>w,=+1<ret>Q

is a macro that will extend a numbered list by copying the current line (using bc on the user = binding)