0% found this document useful (0 votes)
50 views4 pages

Help With Commands: Keyboard Macros

Keyboard macros allow recording and playing back sequences of keys to automate tasks. Commands like F3 and F4 are used to record and playback macros. Help is available through commands like C-h k to view key bindings and C-h f to view command documentation. Emacs also integrates with common tools like make through M-x compile and gdb through M-x gdb to help debug code.

Uploaded by

urdamihai82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views4 pages

Help With Commands: Keyboard Macros

Keyboard macros allow recording and playing back sequences of keys to automate tasks. Commands like F3 and F4 are used to record and playback macros. Help is available through commands like C-h k to view key bindings and C-h f to view command documentation. Emacs also integrates with common tools like make through M-x compile and gdb through M-x gdb to help debug code.

Uploaded by

urdamihai82
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Keyboard Macros

Keyboard macros are a way to remember a fixed sequence of keys for later repetition. They're handy
for automating some boring editing tasks.
F3 Start recording macro
F4 Stop recording macro
F4 Play back macro once
M-5 F4 Play back macro 5 times
M-0 F4 Play back macro over and over until it fails
For example, this sequence of keys does the exact same transformation that we did with regular
expression replacement earlier, that is, it transforms a line containing George Washington to
WASHINGTON, George:
M-d C-d M-u , [SPC] C-y C-n C-a
After we record that key sequence as a macro, we can type M-0 F4 to transform the buffer pictured
earlier; in this case, Emacs runs the macro repeatedly until it has reached the end of the buffer.
See (info "(emacs)Keyboard Macros") for more information.

Help with commands


If you've read this far, you are probably intimidated by the thought of having to remember a bunch of
keyboard commands and command names. Fortunately, Emacs includes comprehensive and easily
accessible documentation. The documentation isn't just for beginners. Emacs has thousands of
commands, of which most people only use a small number. So even Emacs experts frequently consult
the docs in order to learn about new commands or jog their memory on old ones.
If you don't remember what a particular key or command does, you can read a description of it by using
one of the following commands:
C-h k
Shows documentation for the command associated with any particular key.
C-h f
Shows documentation for any particular command, by name (i.e. what you would type after M-
x).

For example, C-h k C-s and C-h f isearch-forward RET both display a page describing
incremental search:
This is handy, for example, if you don't remember what C-s does, or if you remember that it invokes
incremental search but want to know more about that feature. The documentation gives the full name of
the command, shows which (if any) keys are bound to it, and gives a complete description of what the
command does.
On the other hand, if you don't remember how to invoke a particular feature, you can use apropos to
search for it:
C-h a
Search for commands by keywords or regexp

For example, if I remember that I want to activate narrowing, but don't remember how, I can type C-h
a narrow RET which shows a brief list of commands having to do with narrow, one of which is M-
x narrow-to-region.

More useful features


Integration with common tools
Emacs is notable for its integration with many common tools. Not only can you invoke them from
within the editor, Emacs usually helps you use their output more effectively. Here are some examples:
M-x shell

Starts a shell in the buffer named *shell*, switching to it if it already exists. Use C-u M-x
shell to use a buffer with a different name.

M-x compile

Invokes make (with targets and options of your choice) and displays output in a new buffer.
Emacs identifies error lines containing filenames and line numbers, and you can click on them to
jump directly to the corresponding buffer and line.
M-x gdb

Invokes gdb in a new buffer. You can use the gdb command line as usual in that buffer. However,
Emacs lets you set breakpoints directly from your source buffers and shows execution by
marking the active line in your source buffers. Emacs can also display breakpoints, the stack, and
locals, simultaneously and each in their own window.

M-x grep

Invokes grep and prints results in a new buffer. Like M-x compile, when you click on a
match Emacs opens the correct file and takes you to the matching line.

M-x man

Displays man pages.


Here are some more assorted tools:
M-x calculator A simple calculator.
M-x calendar A calendar.
M-x phases-of-moon Shows upcoming quarters of the moon.

Invoking shell commands

You might also like