Emacs Manual Command Summary, Draft 2016-12-21

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Notes to the Emacs Manual

Johannes Choo

CHAPTER 6 EXITING EMACS

Chapter 1

The Organization of the Screen


{Note: TODO}

Chapter 2

Kinds of User Input


{Note: TODO}

Chapter 3

Keys
{Note: TODO}

Chapter 4

Keys and Commands


{Note: TODO}

Chapter 5

Entering Emacs
{Note: TODO}

Chapter 6

Exiting Emacs
2

Key

Command

Description

C-c C-x

save-bufferskill-terminal

Prompt to save buffers, then kill


Emacs.

C-z

suspend-emacs

Suspend Emacs if on a terminal;


minimize Emacs if graphical.

M-x kill-emacs
RET

Kill emacs.

Chapter 7

Basic Editing Commands


7.1

Inserting Text

Key

Command

Description

graphic
character

self-insertcommand

Insert the keys graphic character at


the point.

RET

newline

Start a newline before the point,


and automatic indentation.

C-j

electricnewline-andmaybe-indent

Insert a newline, usually without


indentation.

DEL

deletebackward-char

Deletes the character immediately


before the point.

C-q char

quoted-insert

Insert char before the cursor.

C-q nn

quoted-insert

If nnn is an arbitrary sequence of


octal digits, insert the character
with the corresponding octal
character code. The sequence is
resolved when a non-octal-digit
character is read; that character is
handled as normal input.

C-x 8

prefix key

Prefix for input of Unicode


characters that are also present in
Latin-1.

C-u C-x 8

prefix key

As C-x 8, but inserts n characters


instead of 1.

CHAPTER 7 BASIC EDITING COMMANDS

Key

Command

Description

C-x 8 RET

insert-char

Prompt for Unicode name or


code-point number of a character;
inserts that character before point.

C-u n C-x 8
RET

insert-char

As C-x 8 RET, but inserts n


characters instead of 1.

7.2

Changing the location of point

Key

Command

Description

C-f

forward-char

Move the point 1 character forward.

RIGHT

right-char

Move the point 1 character forward,


but backward if the point is in an rtl
paragraph.

C-b

backward-char

Move the point 1 character


backward.

LEFT

left-char

Move the point 1 character


backward, but forward if the point
is in an rtl paragraph.

C-n,
DOWN

next-line

Move the point down one screen


line.

C-p,
UP

previous-line

Move the point up one screen line.

C-a,
Home

move-beginningof-line

Move the point to the beginning of


the line.

C-e,
End

move-end

Move the point to the end of the


line.

M-f

forward-word

Move the point to the next end of


word.

M-RIGHT

right-word

As forward-word, but as
backward-word if the point is in
an rtl paragraph.

M-b

backward-word

Move the point to the previous start


of word.

M-LEFT

left-word

As backward-word, but as
forward-word if the point is in an
rtl paragraph.

M-<

beginning-ofbuffer

Move the point to the start of the


buffer.

C-u n M-<

beginning-ofbuffer

Move the point to the line just


below n10 of the buffer.

7.3 ERASING TEXT

Key

Command

Description

M->

end-of-buffer

Move the point to the end of the


buffer.

M-r

move-to-windowline-top-bottom

Move the point to the left margin of


the centermost text line of the
window.

M-r M-r

move-to-windowline-top-bottom

Move the point to the left margin of


the topmost text line of the window.

M-r M-r
M-r

move-to-windowline-top-bottom

Move the point to the left margin of


the bottommost text line of the
window.

C-v,
PageDown,
next

scroll-upcommand

Move the window one screen


forward in the buffer, and
reposition the point if necessary.

M-v,
PageUp,
prior

scroll-downcommand

Move the window one screen


backward in the buffer, and
reposition the point if necessary.

M-g c n RET

goto-char

Prompt for a number n, then moves


the pointer immediately before
character n.

M-g TAB n
RET

move-to-column

Prompt for a number n, then moves


the pointer before the n-1 th
character of the current line.

M-g g n RET,
M-g M-g n
RET

goto-line

Prompt for a number n, then moves


the pointer to the beginning of line
number n.

C-u n M-g g,
C-u n M-g
M-g

goto-line

Move the point to the beginning of


line number n.

C-x C-n

set-goal-column

Set the semipermanent goal


column to the current column of
the point. When set, C-p and C-n
will move the point to this column
as well whenever possible.

C-u C-x
C-n

set-goal-column

Unset the semipermanent goal


column.

7.3

Erasing Text

CHAPTER 7 BASIC EDITING COMMANDS

Key

Command

Description

DEL,
BACKSPACE

deletebackward-char

If the region is active, delete the


region; else delete the character
before the point.

Delete

delete-forwardchar

If the region is active, delete the


region; else delete the character after
the point.

C-d

delete-char

Delete the character after the point.

C-k

kill-line

Kill the text between the point and


the end of line; but if the point is at
the end of line, kill the entire line
instead.

M-d

kill-word

Kill the text between the point and


the next end of word.

M-DEL

backward-killword

Kill the text betweed the point and


the previous start of word.

7.4
Key

Command

Description

C-/,
C-_

undo

Undo the last change; repeating it undoes a


yet earlier change.

C-x u

advertised-undo

Alias for undo

7.5

Files

Key

Command

Description

C-x C-f

find-file

Prompts for a file name; then creates a buffer


associated with that filename; then if file is
accessible, copies the contents of the file to
the buffer.

C-x C-s

save-buffer

If the current buffer is associated with a file,


copies the contents of the current buffer to the
associated file.

7.6

Undoing Changes

Basic Help

7.8 CONTINUATION LINES

Key

Command

Description

C-h

prefix key

Prefix key for many help commands.

F1

prefix key

Alias for C-h.

C-h k key

describe-key

Show the command key is bound to and the


help for that command.

7.7

Blank Lines

Key

Command

Description

C-o

open-line

Insert a newline after the point.

C-x C-o

delete-blanklines

If the point is in a run of consecutive


blank lines, collapse them to one. If it
is in a run of one sole blank line, delete
that blank line. If it is on a nonblank
line right before a run of blank lines,
deletes that run of blank lines.

7.8

Continuation Lines

7.9

Cursor Position Information

Key

Command

Description

M-x what-line
RET

Echo the line number of the line


containing the point.

M-x linenumber-mode
RET

When Line-Number mode is on,


display the points line number at
the mode line.

M-x columnnumber-mode
RET

When Column-Number mode is on,


display the points column number
at the mode line.

M-=

count-wordsregion

Echo the number of lines, words,


and characters in the region.

M-x countwords
RET

count-words

Echo the number of lines, words,


and characters in the buffer.

C-x =

what-cursorposition

Echo the character code of the


character after the point, the
character position of point, and the
column of point.

CHAPTER 7 BASIC EDITING COMMANDS

Key

7.10

Description

M-x
hl-line-mode
RET

When Hl-Line mode is on, the line


containing the point on the buffer is
highlighted, and even if the buffer is
inactive.

M-x sizeindication-mode
RET

When Size-Indication mode is on,


display the number of characters in
the current buffer at the mode line.

Numeric Arguments

Key

Command

Description

M- n

digit-argument

n is a digit. Alias for C-u n

M--

negativeargument

Alias for C-u --

C-u

universalargument

Called the universal argument

C-u n

digit-argument

n is a digit. Called a numeric


argument

C-u -- n

negativeargument

n is a digit. Called a negative


argument.

7.11

Command

Repeating a Command

Key

Command

Description

C-x z

repeat

Repeat the previous command with the same


arguments and input. While the next input character
is z, pressing it repeats the command again.

Chapter 8

Minibuffer
8.1

Using the Minibuffer

8.2

Minibuffers for File Names

8.3

Editing in the Minibuffer

Use C-q C-j to insert a newline in the minibuffer, since RET submits the argument.

8.4
8.4.1

Completion
Completion Example

{Note: TODO}

8.4.2

Completion Commands

Completion commands from the minibuffer.


Key

Command

Description

TAB

minibuffercomplete

Complete the text in the minibuffer as


much as possible; if unable to
complete, display a list of possible
completions in another window.

SPC

minibuffercomplete-word

Complete the text in the minibuffer up


to the end of word; if unable to
complete, display a list of possible
completions in another window.

RET

minibuffercomplete-andexit

Submit the text in the minibuffer as


the argument, possibly completing it
depending on the command.

minibuffercompletion-help

Display a list of all completions in


another window.

mouse-1,
mouse-2

mouse-choosecompletion

Clicking on a completion alternative


chooses it.

M-v,
PageUp,
prior

switch-tocompletions

Select the window showing the


completions.

CHAPTER 8 MINIBUFFER

Key

Command

Description

Completion commands from the completion list buffer that has CompletionList mode.
Key

Command

Description

RET

choose-completion

Choose the completion at the point.

RIGHT

next-completion

Move the point to the next completion.

LEFT

previouscompletion

Move the point to the previous


completion.

8.4.3

Completion Exit

{Note: TODO}

8.4.4

How Completion Alternatives are Chosen

{Note: TODO}

8.4.5

Completion Options

{Note: TODO}

8.5

Minibuffer History

Key

Command

Description

M-p

previoushistory-element

Move to the previous item in the


minibuffer history.

M-n

next-historyelement

Move to the next item in the


minibuffer history.

UP

previous-lineor-historyelement

If the point is not on the first line of


a multi-line item, move up one line.
Otherwise, as
previous-history-element.

DOWN

next-line-orhistory-element

If the point is not on the last line of


a multi-line item, move down one
line. Otherwise, as
next-history-element.

M-r regexp
RET

previousmatchinghistory-element

Move to an earlier item in the


minibuffer history that matches
regexp.

10

Key

Command

Description

M-s regexp
RET

next-matchinghistory-element

Move to a later item in the


minibuffer history that matches
regexp.

8.6

Repeating Minibuffer Commands

Key

Command

Description

C-x ESC
ESC

repeat-complexcommand

Re-execute the last command that


used the minibuffer, with the
arguments it was executed with.

C-u n C-x
ESC ESC

repeat-complexcommand

Re-execute the n th last command


that used the minibuffer.

M-x listcommand-history
RET

List the command history of


commands that used the
minibuffer, with the most recent
first.

8.7

Entering Passwords

{Note: TODO}

8.8

Yes or No Prompts

Chapter 9

Running Commands by Name


Key

Command

Description

M-x

execute-extendedcommand

Prompt for a command name to execute.

11

CHAPTER 10 HELP

Chapter 10

Help
{Note: TODO}

10.1

Help Summary

{Note: TODO}

10.2

Documentation for a Key

{Note: TODO}

10.3

Help by Command or Variable Name

{Note: TODO}

10.4

Apropos

{Note: TODO}

10.5

Help Mode Commands

{Note: TODO}

10.6

Keyword Search for Packages

{Note: TODO}

10.7

Help for International Language Support

{Note: TODO}

10.8

Other Help Commands

{Note: TODO}

10.9

Help Files

{Note: TODO}

12

11.2 COMMANDS TO MARK TEXTUAL OBJECTS

10.10

Help on Active Text and Tooltips

{Note: TODO}

Chapter 11

The Mark and the Region


11.1

Setting the mark

Key

Command

Description

C-SPC,
C-@

set-markcommand

Set the mark at point and activate it.

C-x C-x

exchange-pointand-mark

Set the mark at point and activate it,


then move point where the mark
used to be.

Dragmouse-1

TODO

Set the mark where the drag began,


then the point at the end of the
drag.

mouse-3

mouse-davethen-kill

Set the mark at point, then move


point to the location clicked.

Shift selection?

11.2

Commands to Mark Textual Objects

Key

Command

Description

M-@

mark-word

Set the mark at the next end of word.

C-M-@

mark-sexp

Set the mark at the next end of a balanced


expression.

M-h

mark-paragraph

Move the point to the beginning of the


current paragraph, then set mark at the end
of the current paragraph.

C-M-h

mark-defun

Move the point to the beginning of the


current defun, and set the mark at the end of
the current defun.

13

CHAPTER 12 KILLING AND MOVING TEXT

11.3

Operating on the Region

{Note: TODO}

11.4

The Mark Ring

{Note: TODO}

11.5

The Global Mark Ring

{Note: TODO}

11.6

Shift Selection

{Note: TODO}

11.7

Disabling Transient Mark Mode

{Note: TODO}

Chapter 12

Killing and Moving Text


12.1

Deletion and Killing

{Note: TODO}

12.1.1

Deletion

{Note: TODO}

12.1.2

Killing by Lines

{Note: TODO}

12.1.3

Other Kill Commands

{Note: TODO}

12.1.4

Options for Killing

{Note: TODO}

12.2

Yanking

{Note: TODO}
14

15.1 INCREMENTAL SEARCH

12.2.1

The Kill Ring

{Note: TODO}

12.2.2

Yanking Earlier Kills

{Note: TODO}

12.2.3

Appending Kills

{Note: TODO}

12.3

Cut and Paste Operations on Graphical Displays

{Note: TODO}

Chapter 13

TODO Registers
Chapter 14

TODO Display
Chapter 15

Search
15.1

Incremental Search

Key

Command

Description

C-s

isearch-forward

Begin an incremental search forward from


the point.

C-r

isearch-backward

Begin an incremental search backward from


the point.

15

CHAPTER 15 SEARCH

15.1.1

Basics of Incremental Search

Key

Command

Description

C-s

isearch-forward

Begin an incremental search


forward from the point.

C-r

isearchbackward

Begin an incremental search


backward from the point.

RET

isearch-exit

Successfully terminate the


incremental search, leaving the
point at the current match, and
adding the point where the search
started to the mark ring, and adding
the current search string to the
search ring.

ESC ESC
ESC

isearch-cancel

Terminate the current search and


return the point to the location the
incremental search began.

C-g

isearch-abort

If search string is empty or


completely matched, as
isearch-cancel.

15.1.2

Repeating Incremental Search

Key

Command

Description

C-s

isearch-repeatforward

While in an incremental search


forward, search for the next
occurence of a match. If at the end
of the buffer, wraps and continues
the search from the beginning of
the buffer.

C-r

isearch-repeatbackward

While in an incremental search


backward, search for the next
occurence of a match. If at the end
of the buffer, wraps and continues
the search from the end of the
buffer.

M-p

isearch-ringretreat

Cycle backwards in the search ring.

M-n

isearch-ringforward

Cycle forwards in the search ring.

16

15.1 INCREMENTAL SEARCH

Key

Command

Description

M-e,
mouse-1 in
the
minibuffer

isearch-editstring

Begin editing the search string.

RET

exit-minibuffer

While editing the search string,


cease editing.

C-s,

isearchforward-exitminibuffer

As RET, but also set the incremental


search to forward.

C-r

isearchreverse-exitminibuffer

As RET, but also set the incremental


search to reverse.

C-f,
RIGHT

isearch-yankchar-inminibuffer

While editing the search string, with


each successive invocation, append
successive characters following the
point in the buffer to the end of the
search string.

15.1.3

Isearch Yanking

Key

Command

Description

C-w

isearch-yankword-or-char

Append either the next character or


the next word to the search string.
Whether a character or word is
copied is heuristically determined.

M-s C-e

isearch-yankline

Append the rest of the line of the


point to the search string.

C-u n M-s
C-e

isearch-yankline

Yanks the next n lines to the search


string, including the line of the
point.

C-y

isearch-yankkill

Append the most recent kill to the


search string.

M-y

isearch-yankpop

Just after yanking a kill or popping a


kill, pop the next kill.

mouse-2 in
the echo area

isearch-yank-xselection

Append the current X selection to


the search string.

C-M-w

isearch-delchar

Delete the last character from the


search string.

C-M-y

isearch-yankchar

Append the character after the


point to the search string.
17

CHAPTER 15 SEARCH

15.1.4

Errors in Incremental Search

Key

Command

Description

DEL

isearch-deletechar

Undo the last edit of the search string.

C-g

isearch-abort

If the search string is not fully matched,


delete the unmatched part of the current
search string.

15.1.5

Special Input for Incremental Search

Key

Command

Description

M-s SPC

isearch-togglelax-whitespace

Toggle lax space matching.

M-c,
M-s c

isearch-casefold

Toggle case sensitivity of the search.

M-s '

isearch-togglechar-fold

Toggle considering similar characters


(e.g. accented) as equivalent.

M-s i

isearch-toggleinvisible

Toggle whether invisible text is


searched.

M-r,
M-s r

isearch-toggleregexp

Toggle between normal (literal) and


regexp search.

M-s _

isearch-togglesymbol

Toggle symbol search.

C-\

isearch-toggleinput-method

Toggle the input method.

C-

isearch-togglespecified-inputmethod

Prompt to use a non-default input


method.

M-s o

isearch-occur

Invoke occur using the current


search string.

M-%

isearch-queryreplace

Invoke query-replace with the


current search string if in normal
search, or query-replace-regexp
with the current search string if in
incremental regexp.

M-TAB

isearch-complete

Try to complete the search string using


the search ring as completion
alternatives.

18

15.3 WORD SEARCH

Key

Command

Description

M-s h r

isearchhighlight-regexp

Run highlight-regexp with the


regexp from the last search string, and
exit the search.

M-s h u

unhighlightregexp

Remove highlighting of
highlight-regexp.

C-h C-h

isearch-help-map

Access interactive help options related


to incremental search.

As in normal text, use C-j to input a newline character, use C-q or C-x 8 RET
to input other special characters.

15.1.6

Not Exiting Incremental Search

15.1.7

Searching the Minibuffer

15.2

Nonincremental Search

Key

Command

Description

C-s RET string


RET

nonincrementalsearch-forward

Search forward for string.

C-r RET string


RET

nonincrementalsearch-backward

Search backward for string.

M-x search-forward
RET

Simple search forward.

M-x search-backward
RET

Simple search backward.

15.3

Word Search

Key

Command

Description

M-s w

isearchforward-word

Begin a forward incremental word


search.

M-s w from
incremental
search

isearch-toggleword

Make the incremental search a


word search.

M-s w RET
words RET

word-searchforward

Begin a simple word search for


words forward.

M-s w C-r
RET words
RET

word-searchbackward

Begin a simple word search for


words backward.

19

CHAPTER 15 SEARCH

15.4

Symbol Search

Key

Command

Description

M-s _

isearchforward-symbol

Begin a forward incremental


symbol search.

M-s _ from
incremental
search

isearch-togglesymbol

Make the current search a symbol


search.

M-s .

isearchforward-symbolat-point

Begin a forward incremental


symbol search with the symbol at
the point.

M-s _ RET
symbol RET

Simple search forward for symbol.

M-s _ C-r
RET symbol
RET

Simple search backward for symbol.

15.5

Regular Expression Search

Key

Command

Description

C-M-s,
arg C-s

isearchforward-regexp

Begin incremental regexp forward


search. arg is any argument.

C-M-r,
arg C-r

isearchbackward-regexp

Begin incremental regexp backward


search. arg is any argument.

M-r while in
incremental
search

isearch-toggleregexp

Change search to a regexp search.

C-M-s RET

re-searchforward

Begin nonincremental regexp


search forward.

C-M-r RET

re-searchbackward

Begin nonincremental regexp


search backward.

15.6

Syntax of Regular Expressions

15.7

Backslash in Regular Expressions

15.8

Regular Expression Example

15.9

Lax Matching During Searching

20

15.10 REPLACEMENT COMMANDS

Key

Command

Description

M-s SPC

isearch-togglelax-whitespace

Toggles whether the current


incremental search has lax space
matching.

M-c,
M-s c

isearch-togglecase-fold

Toggle case folding.

M-s '

isearch-togglechar-fold

Toggle character folding.

15.10

Replacement Commands

15.10.1
Key

Command

Description

M-x replace-string
RET

Prompt for a string and a newstring. Then,


replace every occurrence of string with
newstring.

15.10.2
Key

Unconditional Replacement

Regexp Replacement

Command

Description

M-x replace-regexp
RET

Prompt for a regexp and a newstring. Then,


replace every match for regexp with
newstring.

15.10.3

Query Replace

Key

Command

Description

M-% string
RET
newstring
RET
C-M-% regexp
RET
newstring
RET

query-replace

Prompt at each match of string to


replace with newstring.

M-p

Cycle back previous replacements.

M-n

Cycle forward previous


replacements.

Prompt at each
match of regexp to
replace with
newstring.

21

CHAPTER 15 SEARCH

During a query replace,


Key

Command

Description

SPC,
y

Replace the current match with newstring and


move to the next occurence.

DEL,
Delete,
BACKSPACE,
n

Skip to the next match without replacing this


current match.

Replace the current match with newstring


without moving to the next occurrence.

RET,
q

Terminate the query replace without any more


replacements.

Replace the current match with newstring, then


terminate query replace.

Perform the current and all remaining


replacements without prompting.

Go back to previous (possibly already replaced)


match.

C-r

Enter a recursive editing level.

C-M-c from
recursive editing
leven

Exit the recursive editing level and proceed to the


next match.

C-w

Delete the current match, then enter a recursive


editing level at the location of the deleted match.

Edit the replacement string in the minibuffer.

RET while editing


the replacement
string

Replace the current match with the edited


replacement string and use the edited replacement
string for following matched.

C-l

Redisplay the screen; does not exit query replace.

Replace all remaining matches in all remaining


buffers in multi-buffer query replace without
prompting.

Move to the next buffer in multi-buffer


replacements without making any further
replacements in the current buffer.

C-h,
?,
F1

Display a summary of query replace options.

22

15.11 OTHER SEARCH-AND-LOOP COMMANDS

15.11

Other Search-and-Loop Commands

Key

o in the occur
list

Command

Description

M-x multiisearch-buffers
RET

Prompt for one or more


RET-delimited buffers, ended by
two consecutive RETs. Begins a
multi-buffer query replace on those
buffers.

arg M-x multiisearch-buffers


RET

Prompt for one or more


RET-delimited buffers, ended by
two consecutive RETs. Begins a
multi-buffer regex query replace on
those buffers. arg is any argument.

M-x
multi-isearchbuffers-regexp
RET

As arg M-x
multi-isearch-buffers RET.

M-x multiisearch-files
RET

Prompt for one or more


RET-delimited filenames, ended by
two consecutive RETs. Begins a
multi-buffer query replace on those
files.

arg M-x multiisearch-files


RET

Prompt for one or more


RET-delimited filenames, ended by
two consecutive RETs. Begins a
multi-buffer regex query replace on
those files. arg is any argument.

M-x
multi-isearchfiles-regexp
RET
M-x occur RET,
M-x listmatching-files
RET

As arg M-x
multi-isearch-files RET.

n M-x occur RET,


n M-x listmatching-files
RET

n is a numeric argument. As M-x


occur RET, but shows n lines of
context before and after the line of
the match.

Display the line containing the


entry in another window and select
that window.

Prompt for a regexp, then display a


list of each line that contains a
match. Click on or input RET on a
list entry to move to the
corresponding line.

23

CHAPTER 15 SEARCH

Key

Command

Description

C-o in the
occur list

Display the line containing the


entry in another window but do not
select that window.

C-x ` in the
occur list

next-error

Display the line containing the next


entry in another window.

e in the occur
list

Switch to Occur-Edit mode; allows


editing the occur list, and these
edits are reflected in the original
lines.

C-c C-c in
Occur-Edit
mode

Return to Occur mode.

M-s o

Run occur with the previous


incremental search string.

M-x multi-occur
RET

Prompts for buffer names, then


performs a multi-buffer occur on
those buffers.

M-x
multi-occur-inmatchingbuffers
RET

Prompts for a regexp, then performs


a multi-buffer occur on buffers
that match the regexp.

M-x how-many
RET

Prompt for a regexp. Then print the


number of regexp matches after the
point. If the region is active, print
instead the number of regexp
matches in the region.

M-x flush-lines
RET

Prompts for a regexp. Delete the


lines of matches starting from after
the point. If the region is active,
have the matches be the matches
within the region instead. If a
match is split across lines, all those
lines are deleted.

M-x keep-lines
RET

Prompts for a regexp. Delete the


lines from the one containing the
point onward if they do not contain
a regexp match. If the region is
active, instead delete lines fully
contained within the region that do
not contain a match. If a match is
split across lines, those lines are
kept.

24

15.11 OTHER SEARCH-AND-LOOP COMMANDS

25

CHAPTER 30 DIRED, THE DIRECTORY EDITOR

15.12

Tailoring Search to Your Needs

Chapter 16

TODO Fixit
Chapter 17

TODO Keyboard Macros


Chapter 18

TODO Files
Chapter 19

TODO Buffers
Chapter 20

TODO Windows
Chapter 21

TODO Frames
Chapter 22
26

TODO International
Chapter 23

30.3 DELETING FILES WITH DIRED

Key

Command

Description

C-x d

dired

Prompt for a directory name, then


open a Dired buffer.

C-x C-f

find-file

Opens Dired if given a folder name.

C-x 4 d

dired-otherwindow

Prompt for a directory name, then


open a Dired buffer in another
window.

C-x 5 d

dired-otherframe

Prompt for a directory name, then


open a Dired buffer in another
frame.

q on Dired
buffer

quit-window

bury the Dired buffer and close the


window that contained Dired if the
window was created just for that
buffer.

30.2

Navigation in the Dired Buffer

Key

Command

Description

C-n

next-line

Move the point to the next line.

n,
SPC

dired-next-line

As C-n.

C-p

previous-line

Move the point to the previous line.

dired-previousline

As C-p.

DEL

dired-unmarkbackward

As p, then unmark the line at point.

dired-goto-file

Prompt for a file name, then move


the point to the line in the buffer for
that file.

M-s f C-s

dired-isearchfilenames

Perform a forward incremental


search in the Dired buffer for file
name matches only.

M-s f
C-M-s

dired-isearchfilenamesregexp

Perform a forward incremental


regexp search in the Dired buffer for
file name matches only.

30.3

Deleting Files with Dired

27

CHAPTER 30 DIRED, THE DIRECTORY EDITOR

Key

Command

Description

dired-flag-filedeletion

Flag the line at point for deletion.

dired-unmark

Unflag and unmark the line at point.

DEL

dired-unmarkbackward

Move the point one line up and then


unflag that line.

dired-do-flaggeddelete

Delete files flagged for deletion.

30.4

Flagging Many Files

Key

Command

Description

dired-flagauto-save-files

Flag all auto-save files for deletion


(files with names that start and end
in #).

dired-flagbackup-files

Flag all backup files for deletion


(files with names that end in ~).

dired-cleandirectory

Flag numeric backup files except


the two oldest and newest backup
versions for deletion.

dired-cleandirectory

If n is a positive numeric argument,


then behaves as ., but keeps the n
newest versions as well instead. If n
is a negative numeric argument,
then behaves as ., but keeps the n
oldest versions as well instead.

% &

dired-flaggarbage-files

Flag for deletion lines that end in


.aux, .bak, .dvi, .log, .orig,
.rej, or .toc.

% d regexp
RET

dired-flagfiles-regexp

Flag for deletion lines whose


filenames match regexp.

30.5

Visiting Files in Dired

Key

Command

Description

f,
e,
RET

dired-find-file

Visit the file of the current line in this


window.

28

30.6 MARKS VS FLAGS

Key

Command

Description

dired-find-fileother-window

Visit the file of the current line in


another window, and select that
window.

C-o

dired-displayfile

Visit the file of the current line in


another window, but do not select that
window.

mouse-1,
mouse-2

dired-mousefind-file-otherwindow

Visit the file of the line clicked on in


another window, and select that
window.

dired-view-file

Visit the file of the current line with


View mode.

dired-updirectory

Visit the parent directory of the


current directory.

30.6

Marks vs Flags

Key

Command

Description

m,
* m

dired-mark

Mark the current line. If the region


is active, mark all lines in the region.

n m,
n* m

dired-mark

If n is positive, mark the next n files,


including the current file. If n is
negative, mark the previous n files,
including the current file.

* *

dired-markexecutables

Mark all lines of executable files.

arg * *

dired-markexecutables

arg is any argument. Unmark all


lines of executable files.

* @

dired-marksymlinks

Mark all lines of symbolic links.

arg * @

dired-marksymlinks

arg is any argument. Unmark all


lines of symbolic links.

* /

dired-markdirectories

Mark all lines of directories, except


for . and ...

arg * /

dired-markdirectories

arg is any argument. Unmark all


lines of directories, except for . and
...

* s

dired-marksubdir-files

Mark all the files in the current


subdirectory, except of . and ...

29

CHAPTER 30 DIRED, THE DIRECTORY EDITOR

Key

Command

Description

u,
* u

dired-unmark

Remove any mark on the line


containing the point. If the region is
active, unmark all the files in the
region instead.

n u,
n* u

dired-unmark

If n is a positive argument, unmark


the next n lines from the point,
including the line containing the
point. If n is a negative argument,
unmark the previous n lines from
the point, including the line
containing the point.

DEL,
* DEL

dired-unmarkbackward

Move point to the previous line,


then remove any mark at that line.
If the region is active, unmark all
lines in the region instead.

n DEL,
n * DEL

dired-unmarkbackward

If n is a positive argument, unmark


the n preceding lines excluding the
current line. If n is a negative
argument, unmark the next n lines
including the line containing the
point.

* !,
U

dired-unmarkall-marks

Remove all marks from all lines in


the buffer.

* ?
markchar,
M-DEL

dired-unmarkall-files

markchar is a single character.


Unmark all characters marked with
markchar.

arg * ?
markchar,
arg M-DEL

dired-unmarkall-files

arg is any argument. Prompts for


each line marked with markchar to
unmark that mark.

* C-p,
M-}

dired-prevmarked-file

Move to the previously marked file.

t,
* t

dired-togglemarks

Files marked with * become


unmarked, and unmarked files
become marked with *. Files
otherwise marked or flagged are
unaffected.

* c
old-markchar
newmarkchar

dired-changemarks

Change all old-markchar marks to


new-markchar marks. SPC in the
stead of old-markchar or
new-markchar refers to being
unmarked.

30

30.7 OPERATING ON FILES

Key

Command

Description

% m regexp
RET,
* % regexp
RET

dired-markfiles-regexp

Mark all lines whose filenames


match regexp. Does not include
searching hidden subdirectories.

% g regexp
RET

dired-markfilescontainingregexp

Mark all lines whose file contents


match regexp; searches the
corresponding buffer if the file is
already open in a buffer, else
searches the file.

C-/,
C-x u,
C-_

dired-undo

Undo changes in the Dired buffer,


such as adding or removing marks.
Using this to undo changes that
correspond to operations to the
actual files may render the buffer
out of sync with the actual directory.

30.7

Operating on Files

For all of the commands in this section, if the command is passed a positive numeric argument n, then operate on the next n lines including the line containing
the cursor. If the command is passed a negative numeric argument n, then operate on the previous n lines including the line containing the point.
Otherwise, if there are marked lines, operate on those lines. Otherwise, operate on the current line.
Key

Command

Description

C new RET

dired-do-copy

If operating on multiple files, copy


the files to the directory new. If
operating on one file, new is the
filename of the copy.

dired-do-delete

Delete the files operated on.

R new RET

dired-do-rename

If operating on multiple files, move


the files to the folder new. If
operating on one file, rename the
file to new.

S new RET

dired-dosymlink

If operating on multiple files, make


symlinks in the folder new to those
files. If operating on one file, make
a symlink named new.

M modespec
RET

dired-do-chmod

Sets the permissions on the files


operated on to modespec, where
modespec is either octal or symbolic
notation.
31

CHAPTER 30 DIRED, THE DIRECTORY EDITOR

Key

Command

Description

G newgroup
RET

dired-do-chgrp

Sets the group owner of the files


operated on to newgroup.

O newowner
RET

dired-do-chown

Sets the owner of files operated on


to newowner.

T timestamp
RET

dired-to-touch

Sets the timestamp of files operated


on to timestamp, where timestamp
is in epoch time.

P command
RET

dired-do-print

Print the files operated on. Prompts


for the print command.

dired-docompress

On the files operated upon,


compress uncompressed files into
each their own archive and
uncompress compressed files.

dired-docompress-to

Prompt for the name of a new


archive. Compress the files
operated on into that archive.

:d

epa-dired-dodecrypt

Decrypt the files operated on.

:v

epa-dired-doverify

Verify digital signatures on the files


operated on.

:s

epa-dired-dosign

Digitally sign the specified files.

:e

epa-dired-doencrypt

Encrypt the files operated on.

dired-do-load

Load the Emacs Lisp files operated


on.

dired-do-bytecompile

Byte compile the Emacs Lisp files


operated on.

A regexp RET

dired-do-findregexp

Search the files and folders for a


match with regexp in their contents.
This is a variant of
xref-find-references.

Q regexp RET
to RET

dired-do-fineregexp-andreplace

Variant of xref-queryreplace-in-results..
Performs a query replace on the
files operated on.

30.8

32

Shell Commands in Dired

30.9 TRANSFORMING FILE NAMES

Key

Command

Description

dired-do-shellcommand

If there are marked files, operate on the


marked files; otherwise, operate on the
line containing point. Prompt for a
command. If the command ends in a &
character, the command is run
asynchronously. If the command ends in ;
or ;&, the command is run in the
background on each file sequentially;
emack waits for each iteration of the
command invocation to terminate before
starting another.
In the command, if * appears with
surrounding whitespace, substitute the
files operated to *. The order of file names
is the order of appearance in the Dired
buffer. Else, if ? appears with surrounding
whitespace, Emacs runs the command
once for each file, substituting the current
filename to ?; ? can appear any number of
times. If neither of the whitespace
surrounded * or ? are present, Emacs runs
the shell command once for each file,
appending the filename at the end of the
command.

n!

dired-do-shellcommand

If n is a positive argument, as !, but


operates on the next n files including the
current line. If n is a negative argument, as
!, but operates on the previous n files,
including the current line.

&

dired-do-asyncshell-command

as !, but commands are run


asynchronously.

n&

dired-do-asynccommand

as n !, but commands are run


asynchronously.

30.9

Transforming File Names

For all of the commands in this section, if the command is passed a positive numeric argument n, then operate on the next n lines including the line containing
the cursor. If the command is passed a negative numeric argument n, then operate on the previous n lines including the line containing the point.
Otherwise, if there are marked lines, operate on those lines. Otherwise, operate on the current line.
All the commands in this section operate interactively; they prompt to confirm
performing the operation on each line.

33

CHAPTER 30 DIRED, THE DIRECTORY EDITOR

Key

Command

Description

% u

dired-upcase

Rename each file operated on to


uppercase.

% l

dired-downcase

Rename each file operated on to


lowercase.

% R regexp
RET to RET

dired-dorename-regexp

Renames the files of lines whose


filenames match regexp to to.

% C regexp
RET to RET

dired-do-copyregexp

Copies the files of lines whose


filenames match regexp to to.

% H regexp
RET to RET

dired-dohardname-regexp

For all files whose lines whose


filenames match regexp, create a
hardlink to them named to.

% S regexp
RET to RET

dired-dosymlink-regexp

For all files whose lines whose


filenames match regexp, create a
symbolic link to them named to.

{Note: TODO: numeric argument}

30.10

Comparison in Dired

Key

Command

Description

dired-diff

Compare the file of the line at point to the file whose


name will be prompted for at the minibuffer with
diff. Print the output of diff to a new buffer in Diff
mode. If the mark is set, the file of the line at the mark
is used to populate the default of the prompt.

30.11

Subdirectories in Dired

Key

Command

Description

dired-maybeinsert-subdir

If the point is on a line corresponding to a


directory, and the directory isnt already
listed in the current buffer, then list the
contents of the subdirectory below.
Otherwise, move to the listing for that
directory.

34

30.15 UPDATING

30.12

TODO Subdir Switches

30.13

Moving Over Subdirectories

Key

Command

Description

C-x ]

forward-page

Move to the next subdirectory header


line.

C-M-n

dired-next-subdir

As C-x ].

C-x [

backward-page

Move to the previous subdirectory


header line.

C-M-p

dired-prev-subdir

As C-x [.

C-M-u

dired-tree-up

Go up to the parent directorys header


line.

C-M-d

dired-tree-down

Go down to the first subdirectorys


header line.

<

dired-prevdirline

Move to the previous line that


corresponds to a directory file.

>

dired-nextdirline

Move to the next line that corresponds


to a directory file.

30.14

Hiding Subdirectories

Key

Command

Description

dired-hide-subdir

Toggle hiding and showing the subdirectory


the point is in. When a subdirectory is
hidden, only its header line is displayed.

M-$

dired-hide-all

Hide all subdirectories in the Dired buffer if


no subdirectories are hidden; if all
subdirectories are hidden, make all
subdirectories visible again.

30.15

Updating

Key

Command

Description

revert-buffer

Update the contents of the Dired


buffer.

35

CHAPTER 30 DIRED, THE DIRECTORY EDITOR

Key

Command

Description

dired-doredisplay

If the command is passed a positive


numeric argument n, then operate
on the next n lines including the
line containing the cursor. If the
command is passed a negative
numeric argument n, then operate
on the previous n lines including
the line containing the point.
Otherwise, if there are marked lines,
operate on those lines. Otherwise,
operate on the current line. Update
the files operated on.

dired-do-killlines

If the command is passed a positive


numeric argument n, then operate
on the next n lines including the
line containing the cursor. If the
command is passed a negative
numeric argument n, then operate
on the previous n lines including
the line containing the point.
Otherwise, if there are marked lines,
operate on those lines. Otherwise,
operate on the current line. Kill the
file lines operated on. If a directory
line is killed, then also kill their
corresponding subdirectory listing,
if displayed.

dired-sortdottle-or-edit

Toggle between alphabetical order


and date/time order.

C-u s
switches RET

dired-listingswitches

Refresh the buffer passing switches


to the ls program used.

36

30.15 UPDATING

37

CHAPTER 53 TODO LOSSAGE

30.16

TODO Find

30.17

TODO Wdired

30.18

TODO Image-Dired

30.19

TODO Misc

Chapter 31

TODO Calendar/Diary
Chapter 32

TODO Sending Mail


Chapter 33

TODO Rmail
Chapter 34

TODO Gnus
Chapter 35

TODO Host Security


Chapter 36
38

TODO Network Security


Chapter 37

You might also like