I use keyboard macros in one buffer like this:

'C-x (’ or <f3>– start defining a keyboard macro
`C-x )’ or <f4>– stop defining the keyboard macro

Nice. It's work fine. But I use macro in on buffer. But suppose I has 2 buffers. I split window. In the top I has countries.xml and in bottom buffer I has insert-data.sql

Is it possible to create keyboard macro that copy data, line by line, from insert-data.sql and paste to countries.xml ?

Here screenshot:


I know that I can write elisp script. But I want to do this task by keyboard macros. Is it possible?

  • 4
    You can simply switch windows or buffers in your macro, but you have to make sure your macro ends up with a reasonable state so it can be repeated.
    – user12563
    May 8, 2018 at 10:31
  • [@DoMiNeLa10]: I think you answered well.
    – Marco Wahl
    May 8, 2018 at 11:21

1 Answer 1


As noted in the comments, you can include buffer-switching in your macro as long as you're consistent about where you start/end.

Another approach might be to use commands in your macro that keep you in one buffer but allow you to push text to the other one, such as append-to-buffer or prepend-to-buffer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.