help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I bind a macro to a key?


From: address@hidden
Subject: Re: How do I bind a macro to a key?
Date: Fri, 10 Oct 2003 00:04:26 -0400
User-agent: KNode/0.7.1

Dan Anderson wrote:

> Is it possible to create a macro and bind it to a key (or set of keys)
> for the rest of the session?  Sometimes when programming I'll find I
> need like 5 separate macros, and I don't know how to C-x e each one
> separately except for creating one, running down the code and running
> it, and creating another.  This seems very inefficient.  Is there a
> better way?
> 
> Thanks in advance,
> 
> Dan

Sure. After you create your macro name it with:

M-x name-last-kbd-macro

Give it a name and it becomes a command beginning with the usual M-x.

If you want to go one step further and come up with a shortcut, use:

M-x global-set-key

That'll bind it to whatever shortcut you like. Emacs already has a bunch of 
shortcuts set aside for assignment. They begin with C-c and then a letter.

Unless you actually save these macros and shortcuts by inserting them into a 
file, they disappear when you close Emacs.

Enjoy!

--Rod

-- 
Author of "Linux for Non-Geeks--Clear-eyed Answered for Practical Consumers" 
and "Boring Stories from Uncle Rod." Both are available at 
http://www.rodwriterpublishing.com/index.html

To reply by e-mail, take the extra "o" out of the name.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]