[emacs] save a macro

Once you have recorded a macro, you can save it for later usage on a file (or within your .emacs). The steps to follow in order to get this work, is (1) give a name to the macro, (2) insert it into a buffer.

M-x name-last-kbd-macro RET my-cool-macro-name

then (what I usually do), open a buffer for saving it and insert the macro into it

C-x C-f ~/my-buffer.el ;;open a new (or existing one) file.
M-x insert-kbd-macro RET my-cool-macro-name ;;insert the macro into the buffer
C-x C-s ;;save the buffer

Now, it’s time to use the saved macro. If you have saved it in your .emacs you’ll have it ready on every emacs startup, otherwise it’s enough to load the .el file when needed (I prefer this way)

M-x load-file RET ~/my-buffer.el

Advertisements

One thought on “[emacs] save a macro

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s