3 ms·
<Keyboard macros are dope. My keys are bound to f3 and f4 but I don't remember if that's standard. Basically you hit f3 to open a macro, do some stuff, and then
by OvidNaso 10y ago
<Keyboard macros are dope. My keys are bound to f3 and f4 but I don't remember if that's standard. Basically you hit f3 to open a macro, do some stuff, and then hit f4 to close it. Then you hit C-x e to execute it from the point, and hit e repeatedly to keep executing it. Super convenient. As an example, you might make a macro where you move the point to the beginning of the line, deletes 2 characters of whitespace, then moves to the next line. But you gotta be careful it's actually gonna do what you want; you'll get better at this over time. You generally have to imagine the point exists at a random point in a line, and find how to get it to where it needs to go, before you're able to do the real work of the macro.
Macros combine great with another amazing feature: registers. Hit C-x C-k b [0-9] and the macro can be called with C-x C-k [number chosen]. This way you can quickly use multiple macros. You can also C-x C-k n NAME to save the macro as a callable function and if you then decide that it would be useful in the future, just call insert-kbd-macro and emacs will generate the lisp code that defines your macro and you can put that in your init.el.
- tripa 10y agoThird person I see running last macro with C-x e. In my setup, and I think it's standard, repeating f4 is enough.
- _asummers 10y agoInteresting, I'll have to try that. When I found macros, I did open with C-x ( and close with C-x ), so C-x e makes sense. Then I found f3 and f4 and didn't bother to unlearn that binding.