Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [keyboard-macros]

A "keyboard macro" is a command defined by an Emacs user which represents a sequence of keys. Calling a keyboard macro is equivalent to typing that key sequence.

Filter by
Sorted by
Tagged with
1 vote
1 answer
57 views

How do I load a previously named keyboard macro?

If I've previously defined a keyboard macro via C-x ( and C-x (i.e. kmacro-{start,end}-macro), named it via C-x C-k n (kmacro-name-last-macro), and then recorded a bunch of other macros in the same ...
Adam Spiers's user avatar
0 votes
2 answers
130 views

how to replace Hyperbole implicit action buttons with equivalent org-mode functionality?

I like using the Hyperbole implicit buttons as a very easy way to take actions by just doing M-RET on some text -- for example, I want to jump straight to the org-mode agenda for the day, so I put {C-...
Dan Drake's user avatar
  • 625
2 votes
1 answer
52 views

'Hey Keyboard Macro, talk to me!' — 'Okay.'

Keyboard Macros - recording a sequence of keystrokes - start by 'C-x (' and end by 'C-x )' - to be replayed - for example by 'C-x e' - is such a useful tool. It's like the perfect stepping stone ...
starquake's user avatar
0 votes
0 answers
91 views

"if: No catch for tag: emacs-version-changed, nil" when trying to insert keyboard macro

I'm trying to define a keyboard macro that will double space a region of text. After I highlighted the region of text that I want to double space, I tried both evil-record-macro and kmacro-start-macro ...
Blender's user avatar
  • 25
0 votes
2 answers
53 views

How to insert kbd macros in Yas-snippets?

I'm trying to learn how to: Define a kbd-macro, (here I'm using kbd-macros, because I'm bad at elisp currently). Letting that to be executed when yas-snippet to expand. (here I'm struggling with) My ...
Garid's user avatar
  • 641
1 vote
1 answer
49 views

How to remove the whitespace on the beginning of every expression on this Clojure code snippet?

I have the following Clojure code snippet: { :id "SchK-Cash-contributions-(60%)" :description "Schedule K - Cash contributions (60%)" :line "L12a" :ultratax-...
Pedro Delfino's user avatar
3 votes
1 answer
60 views

Documenting keyboard macros Can I have a doc string for fset the same way as defun

I often create and save elaborate keyboard macros that I wish to use later, and hope to be prompted for the proper context to use them. I note that if I manually write a function to use as a command ...
Chip Grandits's user avatar
1 vote
0 answers
22 views

Repeate keyboard macro (e) doesn't work when I ace-jump-window/aw-flip-window to another frame

If I use ace-jump-window's aw-flip-window functionality in the middle of defining a macro (i.e. switch to the last window - I want which windows I jump between to be dynamic, not fixed to the current ...
John Graham's user avatar
1 vote
1 answer
93 views

Elisp function to transform word at point

How to write an elisp function that transforms the word at point? Specifically, in the C++ code I am refactoring I have to replace tons of raw pointers into smart pointers. Say, for class Foo, I would ...
Joachim W's user avatar
  • 145
0 votes
3 answers
86 views

How do I convert a `matrix` in one form to a `matrix` in another form (like `bmatrix` environment)

I'm attempting to take faster linear algebra notes within org-mode. The latex of a matrix is complex to write, so I'm trying to develop a shorthand expansion. My current workflow is to highlight a ...
Justin Abrahms's user avatar
1 vote
4 answers
94 views

how to define keyboard macro from text

I am using shell inside Emacs. Often I need to execute a series of shell commands around ~40 chars, as of now I copy all the commands together and paste it from documentation. Is there any way to ...
GOPS's user avatar
  • 11
1 vote
1 answer
25 views

Simple keyboard macro to jump to \begin{document} regardless of current location in file

If you are in the preamble of a TeX document you can do C-s \begin{document} or C-r \begin{document} if you are in the body of the document. It would useful to have a simple, all-purpose macro (say, M-...
sgmoye's user avatar
  • 179
2 votes
2 answers
305 views

Emacs 28: How to use `RET` without exiting a recursive edit within a keyboard macro?

Now that I switched to using GNU Emacs 28.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2022-05-11 I can no longer end my use of my keyboard macro that ...
Alan Wehmann's user avatar
1 vote
1 answer
97 views

How to write a Lisp representation of a keyboard macro and bind it to a command name?

I'm using spacemacs with vim-bindings, but I only mention it so you don't scratch your head too long at the keystrokes of the macro. A regular emacs solution will work just the same. I've read through ...
mcp's user avatar
  • 556
0 votes
0 answers
21 views

How to control behavior of command storage for macro repeat?

There are some actions which I would like to repeat however repeating the action doesn't work as I would like it to. Take dabbrev, if I repeat a dabbrev completion, the result may be different based ...
ideasman42's user avatar
  • 8,826
2 votes
1 answer
20 views

shortcut to select data to the last row

I'm new to Emacs. First of all sorry if my English is weird because it is not my first language. I don't know much about the terminologies used in Emacs. Currently, I'm just using Emacs for data ...
hardifrjt's user avatar
2 votes
0 answers
55 views

How to edit keyboard macro saved in file?

Here is my custom keyboard macro: (fset 'gen-numbers (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (...
a_subscriber's user avatar
  • 4,124
3 votes
2 answers
63 views

count-matches' result in kill-ring?

I'm trying to create a keyboard macro to generate a report which displays the number of times a certain string occurs. I have two buffers, with all the strings to look for(on a separate line) the ...
dr jerry's user avatar
  • 331
1 vote
1 answer
62 views

How to automate the test step in "debugging by bisection"?

Sometimes I run into a problem with Emacs that goes away if invoke Emacs with the --no-init-flag. In other word, I can deduce that the problem in question is caused by code somewhere in my .emacs file....
kjo's user avatar
  • 3,247
0 votes
0 answers
43 views

Make undo during I-search revert last call to ding

Entering a failing search string during I-search triggers a call to ding(). If this happens during a macro recording that ding when the macro is being played will abort the macro which in turns ...
Nordlöw's user avatar
  • 507
2 votes
0 answers
26 views

Is it possible to control how a command is recorded as a keyboard macro?

Some actions don't work well when repeated in a keyboard macro. For example, dabbrev-expand may give a different expansion based on the surrounding context. I would like to repeat the action as if I ...
ideasman42's user avatar
  • 8,826
1 vote
1 answer
69 views

How to tell, with Elisp, whether a command is running as part of a keyboard macro?

In some situations a command will use timers or hooks in a way that doesn't work when repeating as a keyboard macro. How can I detect if a function is running as part of a keyboard macro that is being ...
ideasman42's user avatar
  • 8,826
0 votes
1 answer
103 views

Do something for all regular expression matches

I have a named-and-saved keyboard macro that I want to apply to all regular expression matches. How to do that? (Related: I found this stackoverflow post: Running a macro till the end of text file in ...
Inspired_Blue's user avatar
1 vote
1 answer
78 views

how to end macro expansion in *scratch* buffer and return to writable buffer

In scratch buffer, Emacs can expand macros(C-c e; macrostep-expand). But once I expanded the macro, it seems to become a read-only buffer. I don't know how to end macro expansion and return to ...
R. Y's user avatar
  • 11
0 votes
1 answer
235 views

`C-c C-c` compilation stopped working in SLIME but works if manually typed, how to fix it?

I am new to Emacs and Slime. I have been using both of them daily for the last 10 days. And it is amazing! I am impressed. Today, I decided to install and try the package Paredit. Not sure if this is ...
Pedro Delfino's user avatar
0 votes
0 answers
206 views

Kill buffers - how to make *scratch* and *Messages* last

Any setting I can use to get back the old behavior where killing a buffer I get to the next buffer for the files I have given on the command line? I have been using Emacs like this for years Open ...
kboortz's user avatar
  • 11
0 votes
1 answer
98 views

Change vertical characters to horizontal

I have the following data and want to change from Code 1 to Code 2. Is there any useful method to do that? Code 1 11130101 11130102 11130201 Code 2 11130101, 11130102, 11130201
hrkshr's user avatar
  • 143
3 votes
1 answer
51 views

How to write documentation for saved keyboard macros?

I have recently defined a keyboard macro using C-x ( and C-x). I then gave the keyboard macro a name using M-x name-last-kbd-macro RET defined-kbd-macro. And saved it to a file using M-x insert-kbd-...
Tian's user avatar
  • 288
1 vote
1 answer
78 views

How to duplicate text but increment a numeric part of a name?

Say that I have rect1 one and I'll multiply it 3 times by yanking. let rect1 = Rectangle { width: 10, height: 40, } let rect1 = Rectangle { width: 10, height: 40, } ...
zoldseges's user avatar
0 votes
1 answer
186 views

Execute function by using evil-set-register

I use evil and I want to execute a function by using Emacs macro system. Let's say I have the following macro. (evil-set-register ?f [?i ?f ?o ?o ?b ?a ?r escape]) I can run the macro by using @f. ...
itirazimvar's user avatar
0 votes
0 answers
116 views

How to run a keyboard macro (saved in my init.el) automatically when Emacs starts up?

I have saved a keyboard macro in my init.el file as follows (fset 'remember-notes-my-macro (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-...
aks's user avatar
  • 145
1 vote
1 answer
41 views

How to reference the contents of a variable in a keyboard macro definition?

I have a macro called f5, which I globally bind the keyboard key <f5> to: (fset 'f5 [?i ?\[ ?* ?* ?P ?1 ? ?\] escape ?h ?a]) (global-set-key (kbd "<f5>") 'f5) So when I ...
Mr Colin M Kendall's user avatar
0 votes
1 answer
214 views

How to overwrite by pasting a string without selecting a region?

I can't figure out how to paste a string, for example 145 characters long, into a text line in a way, that the next 145 characters after the string are overwritten by this string or simply erased. An ...
starquake's user avatar
0 votes
1 answer
16 views

Get keyboard macro mapping

What functionality is available in emacs to get information about a keyboard macro? Even something as simple as printing out what the macro evaluates.
Ian Melendez's user avatar
1 vote
0 answers
134 views

How do I disable Swiper while defining a keyboard macro?

I don't like the swiper behavior when interactively defining a macro, it is slow and seems to cause other problems. How can I revert bound keys to isearch-forward and isearch-backward when defining ...
testUser12's user avatar
1 vote
0 answers
84 views

keyboard macro with input-method inserts characters twice

When I define keyboard macro with some input method enabled (lets say, english-dvorak), self-insert commands are repeated twice. For example, if I define macro like this: F3insert chars asdfF4 and ...
Sergey's user avatar
  • 259
3 votes
2 answers
678 views

How do I get an initial M-x argument?

I use an asterisk in my function names, so that to execute one of my own functions, I would begin by typing M-x *. Now I would like to save myself a keystroke and achieve the same by M-X. How do I ...
Toothrot's user avatar
  • 3,264
0 votes
0 answers
16 views

How to execute a keyboard macro until termination inside another one, without stopping the recording?

I have a buffer with the following content and I need to delete the duplicate lines. 57,04/15/2020 03:02PM,'Weight'='2.478 lb','tare'='0.918 lb' 57,04/15/2020 03:02PM,'Weight'='2.478 lb','tare'='0....
Swedgin's user avatar
  • 219
3 votes
1 answer
346 views

Emacs keyboard macros ? all over

I have used keyboard macros for a long time, but moved between companies, systems, and various machines over my career. I used to be able to record macros and insert-kbd-macro into my .emacs file and ...
kmcaron's user avatar
  • 31
0 votes
1 answer
40 views

Customizing f6-key for fast "M-x imenu" + "Pr" + Enter

I wish to customize my f6key so it corresponds to a fast way of doing M-x imenu, then Pr RET. I've added the following to my ~/.emacs: (global-set-key [f6] 'imenu) Then I've tried to add different ...
Okay Dokey's user avatar
2 votes
1 answer
319 views

Associate (and save) macro with current file (+/- evil spacemacs)

After edit : I am using evil-mode. I often record macros very specific to the file I am editing with qq or qw. Is there a way to autosave those macros and the key associated to them when saving the ...
pietrodito's user avatar
1 vote
0 answers
71 views

isearch in kmacro-step-edit-macro

I'm trying to edit a keyboard macro using kmacro-step-edit-macro. The macro starts by isearching for a word. C-s ;; isearch-forward binary_function ;; self-insert-command * 15 RET ...
Joel Nises's user avatar
1 vote
3 answers
288 views

How to create loops for inserting text?

Imagine I want to create a list with 10 items, i. e. 1. 2. 3. ... 10. In Vim I can use the command :for i in range(1,10) | put =i.'. ' | endfor for this. How can I do the same thing in Emacs? ...
Glory to Russia's user avatar
1 vote
0 answers
81 views

Simple regexp inside emacs keyboard macro

Newbie question: I'm trying to record a keyboard macro with a simple regexp inside (search-backward-regexp ^[0-9]). This works well when recording the macro, but as soon as I try to execute it, the ...
Joachim's user avatar
  • 11
3 votes
1 answer
244 views

alphabetic keyboard macro "counter"?

I very much {like, use} the kmacro-*-counter family of commands. However I sometimes find myself needing to generate alphabetic sequences (e.g., A, B, C, ...) instead of integer sequences (e.g., 1, 2, ...
TomRoche's user avatar
  • 632
0 votes
1 answer
331 views

keyboard macro for opening a file

How can I create a keyboard macro where a file myfile is opened by executing M-x openmyfile. The main part should look like (fset 'openmyfile [?\C-x ?\C-f <dir of myfile> return]) but I don'...
pawel_winzig's user avatar
3 votes
1 answer
161 views

Octal character representation in keyboard macros

I generated a macro as a help for generating indices for words I have marked before. Now this macro looks as follows (fset 'index "\367\\index{\C-y") What does \367stand for and where can I look ...
pawel_winzig's user avatar
0 votes
1 answer
312 views

How can I apply a keyboard macro to every line that starts with rectangle mark region

Lets suppose I would like to edit my text and to add comments to the column in the text. This is my text: something-text1 foobar1 something-text1 something-text2 foobar2 something-text2 --- ...
Pfedj's user avatar
  • 338
2 votes
0 answers
149 views

execute-kbd-macro apparently not working according to its doc?

The doc of execute-kbd-macro says: (execute-kbd-macro MACRO &optional COUNT LOOPFUNC) ... If MACRO is a symbol, its function definition is used. I tried M-: (execute-kbd-macro 'ignore). ...
Tobias's user avatar
  • 33.2k
0 votes
1 answer
57 views

Creating a macro to change dictionary and run ispell

I would like to create a simple key binding (e.g. C-c s e) to spell check the (mu4e) email message I am composing using English (and use other bindings for other languages). I thought I'd simply ...
AstroFloyd's user avatar