Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-11-2005, 02:27 PM   #1
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
Question Emacs copy predefined text

When editing code in emacs, I'd like to have a prewritten template containing a comment that can be modified to explain each function. I was wondering how I could write this template in a text file somewhere, then tell emacs to insert that text every time a particular key combination is pressed.
Old 09-11-2005, 03:07 PM   #2
Senior Member
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 52
emacs can do macros

Cntrl x (
type your macro
Cntrl x )

Cntrl g to cancel if you get mesed up
to execute the last macro you made Cntrl x e

to save
ESC x (or Alt x) name-last-kbd-macro
<type a name>

to use ESC x name

to save permanently in .emacs file
open .emacs and ESC >
ESC x insert-kbd-macro
<macro name>
Cntrl x Cntrl s

to use it
ESC x macroname
Old 09-11-2005, 03:44 PM   #3
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Original Poster
Rep: Reputation: 30
Perfect, thanks. Is there a way to simplify ESC-x macroname? (e.g. unset whatever is bound to Ctrl-P and assign it instead to invoke that macro)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 11:28 AM
text encoding, emacs and LaTeX. bnj Linux - Newbie 2 10-13-2005 07:56 AM
Copying text from firefox into emacs MDBlueIce Linux - Software 1 05-22-2005 03:58 PM
copy pasting in emacs wogga Linux - Software 7 06-16-2004 03:12 PM
EMACS-text editor TrippyChik Linux - Software 10 10-17-2003 09:36 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:21 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration