When you use {{Keys|C-x C-f}} to invoke command find-file, Emacs opens the file you request, and puts its contents into

−

find-file, Emacs opens the file you request, and puts

+

a buffer with the same name as the file. Instead of thinking that you are editing a file, think that you are editing

−

its contents into a buffer with the same name as the file. Instead of thinking that you are editing a file, think that you are editing text in a buffer. When you save the buffer, the file is updated to reflect your edits.

+

text in a buffer. When you save the buffer, the file is updated to reflect your edits.

−

Buffers can also contain text that doesn't come from a file. When you

+

Buffers can also contain text that doesn't come from a file. When you use {{Keys|C-x C-b}} to get a list of buffers,

−

use {{Keys|C-x C-b}} to get a list of buffers, that

+

that list is itself in a buffer, called <tt>*Buffer List*</tt>, and that buffer is not associated with any file.

−

list is itself in a buffer, called

+

−

<tt>*Buffer List*</tt>, and that buffer is not associated with any file.

+

−

By convention, buffers whose names start with an asterisk ('''`*'''')

+

By convention, buffers whose names start with an asterisk ('''`*'''') are not associated with files (but that doesn't

−

are not associated with files (but that doesn't mean you can't save them in files). If they have unsaved changes when you exit Emacs, these buffers are killed without your being asking for confirmation.

+

mean you can't save them in files). If they have unsaved changes when you exit Emacs, these buffers are killed without

+

your being asking for confirmation.

−

Buffers whose names start with a space are [[InvisibleBuffers|invisible]] to many operations. These are generally internal buffers that you don't want to see. Their names normally don't appear in the buffer list or as

+

Buffers whose names start with a space are [[InvisibleBuffers|invisible]] to many operations. These are generally

−

[[Completion|completion]] candidates when you switch buffers using {{Keys|C-x b}}.

+

internal buffers that you don't want to see. Their names normally don't appear in the buffer list or as

+

[[Completion|completion]] candidates when you switch buffers using {{Keys|C-x b}}.

−

Buffers are shown in [[#window|windows]]. You can have more than one

+

Buffers are shown in [[#Window|windows]]. You can have more than one window showing the same buffer. {{Keys|C-x 2}}

−

window showing the same buffer. {{Keys|C-x 2}} splits the

+

splits the current window, creating two windows, both showing the same buffer.

−

current window, creating two windows, both showing the same buffer.

+

−

You can find more info on buffers in the Emacs manual:

+

You can read more about windows in the Emacs manual:

* {{Manual|emacs|Buffers|Buffers}}

* {{Manual|emacs|Buffers|Buffers}}

* {{Manual|emacs|Windows|Windows}}

* {{Manual|emacs|Windows|Windows}}

Line 26:

Line 26:

−

= Window =

+

== Window ==

−

In Emacs terminology, a "window" is a container in which a [[buffer]] is displayed.

+

In Emacs terminology, a "window" is a container in which a [[#Buffer|buffer]] is displayed. This may be confusing at first; if so, think "pane" whenever you see "window" in an Emacs context until you get used to it.

−

When starting an Emacs [[#frame]], there is ordinarily only one window in it, which can be split into multiple windows using {{Keys|C-x 2}} or {{Keys|C-x 3}}. This allows viewing different [[#buffer|buffers]] (or multiple times the same [[#buffer]]) at once.

+

A new Emacs [[#Frame|frame]] contains one window. This window can be split in to multiple windows using:

You can use multiple windows to view different [[#Buffer|buffers]] (or different portions of the same [[#Buffer|buffer]]) at once.

You can read more about windows in the Emacs manual:

You can read more about windows in the Emacs manual:

Line 36:

Line 40:

* {{Manual|emacs|Windows|Windows}}

* {{Manual|emacs|Windows|Windows}}

+

== Frame ==

+

In Emacs terminology, a "frame" is what most window managers (Windows, OSX, GNOME, KDE, etc.) would call a "window".

−

= Frame =

+

It will typically have a title bar and some buttons to iconify (minimize), maximize / restore, and close the frame. To

+

see an example, open up a second frame from your running Emacs instance with {{CommandKeys|C-x 5 2|make-frame-command}}. You can close frames with {{CommandKeys|C-x 5 0|delete-frame}}, though this

+

will not close the last frame that is open.

−

In Emacs terminology, a "frame" is what most window managers (Windows, OSX, GNOME, KDE, etc.) would call a "window".

+

To be completely correct, frames can be created when Emacs is running in terminal mode too, not just in a windowing system. They don't provide the same visual cues but otherwise work the same.

−

It will typically have a title bar and some buttons to iconify (minimize), maximize / restore, and close the frame. To see an example, open up a second frame from your running Emacs instance with {{Keys|C-x 5 2}} (<code>make-frame-command</code>). You can close frames with {{Keys|C-x 5 0}} (<code>delete-frame</code>), though this will not close the last frame that is open.

You can read more about frames in the Emacs manual:

You can read more about frames in the Emacs manual:

Line 48:

Line 55:

* {{Manual|emacs|Frames|Frames}}

* {{Manual|emacs|Frames|Frames}}

+

== Point ==

+

+

The active cursor shows the location at which editing commands will

+

take effect, which is called "point". Many Emacs commands move

+

point to different places in the buffer; for example, you can place

+

point by clicking mouse button 1 (normally the left button) at the

+

desired location.

+

+

If you use a block cursor, the cursor appears to be on a

+

character, but you should think of point as between two characters;

+

it points before the character that appears under the cursor. For

+

example, if your text looks like `frob' with the cursor over the `b',

+

then point is between the `o' and the `b'. If you insert the character

+

`!' at that position, the result is `fro!b', with point between the `!'

+

and the `b'. Thus, the cursor remains over the `b', as before.

+

+

Sometimes people speak of "the cursor" when they mean "point," or

+

speak of commands that move point as "cursor motion" commands.

+

+

+

You can read more about the point in the Emacs manual:

+

* {{Manual|emacs|Point|Point}}

+

+

+

+

== The Mark and the Region ==

+

+

Many Emacs commands operate on an arbitrary contiguous part of the

+

current buffer. To specify the text for such a command to operate on,

+

you set "the mark" at one end of it, and move point to the other end.

+

The text between point and the mark is called "the region". The region

+

always extends between point and the mark, no matter which one comes

+

earlier in the text; each time you move point, the region changes.

+

+

+

You can read more about the mark and the region in the Emacs manual:

+

* {{Manual|emacs|Mark|Mark}}

+

+

+

+

== Killing ==

+

+

In Emacs, "killing" means erasing text and copying it into the "kill

+

ring". "Yanking" means bringing text from the kill ring back into the

+

buffer. (Some applications use the terms "cutting" and "pasting" for

+

similar operations.) The kill ring is so-named because it can be

+

visualized as a set of blocks of text arranged in a ring, which you can

+

access in cyclic order.

+

+

+

You can read more about killing in the Emacs manual:

+

* {{Manual|emacs|Killing|Killing}}

+

+

+

+

== Yanking ==

+

+

"Yanking" means reinserting text previously killed. The usual way to

+

move or copy text is to kill it and then yank it elsewhere one or more

+

times.

+

+

You can read more about Yanking in the Emacs manual:

+

* {{Manual|emacs|Yanking|Yanking}}

+

+

+

+

== Faces ==

+

+

Emacs can display text in several different styles, which are called faces. Each face can specify various face attributes, such as the font, height, weight and slant, the foreground and background color, and underlining or overlining. A face does not have to specify all of these attributes; often it inherits most of them from another face.

+

+

On a text-only terminal, not all face attributes are meaningful. Some text-only terminals support inverse video, bold, and underline attributes; some support colors. Text-only terminals generally do not support changing the height, width or font.

+

+

Most major modes assign faces to the text automatically through the work of Font Lock mode. See Font Lock, for more information about Font Lock mode and syntactic highlighting. You can print the current buffer with the highlighting that appears on your screen using the command {{Command|ps-print-buffer-with-faces}}.

+

+

+

You can read more about faces in the Emacs manual:

+

* {{Manual|emacs|Faces|Faces}}

+

+

+

+

== Major mode ==

+

+

Emacs can adapt its behaviour to the specific type of text edited in a buffer. The set of specific Emacs customizations for a particular type of text is called a "major mode". Each buffer has exactly one major mode depending on its content type (but see [[MuMaMo]] for a way to relax this constraint).

+

+

Major modes can change the meaning of some keys, define syntax highlighing or indentation rules, and install new key bindings (usually beginning with {{Keys|C-c}}) for mode-specific commands. Emacs ships with a wide range of major modes, falling into three main categories:

In Emacs ''filling'' text means breaking it in to lines of a given maximum width. You can enable automatic filling with {{Command|auto-fill-mode}}, or fill a specific block of text using something like {{CommandKeys|M-q|fill-paragraph}}.

+

+

Note that fill commands add hard line breaks to the text. This is different from what might be called "word wrap" (or "line wrap") in other tools, where the text is wrapped at the edge of the current display and re-flowed if the window is resized. Emacs provides this sort of wrapping as well, see [[#Screen Lines]]

+

+

You can read about the various ways to fill text in the Emacs manual:

+

* {{Manual|emacs|Filling|Filling}}

+

+

== Screen Lines ==

+

+

Emacs provides several ways to deal with text lines that extend horizontally beyond the size of the current window. These are display features: they change the ''screen lines'' shown in the window without modifying the ''logical lines'' of the actual text.

+

+

* By default, Emacs wraps a long line of text at the edge of the window and shows the remaining text in ''continuation lines''.

+

* [[Visual Line]] mode provides what is commonly called "word wrap": long lines are wrapped at the edge of the window without breaking in the middle of a word. Try {{Command|visual-line-mode}}.

+

* ''Line truncation'' means that text beyond the edge of the display is simply not shown, i.e. the line is cut off. Try {{Command|toggle-truncate-lines}}.

+

+

These display options can affect how some editing and movement commands work. Refer to the documentation for details. To reformat text with hard line breaks, see [[#Fill]].

+

+

You can read more about the various ways of visualizing long lines in the Emacs manual:

+

* {{Manual|emacs|Continuation-Lines|Continuation Lines}}

+

* {{Manual|emacs|Visual-Line-Mode|Visual Line Mode}}

+

* {{Manual|emacs|Line-Truncation|Line Truncation}}

+

+

+

== case-fold ==

+

+

Case '''in'''sensitivity.

+

== Narrow and widen ==

−

= Point and mark =

+

Sometimes you want to work on just a portion of the current buffer and ignore the rest. Emacs provides commands to ''narrow'' the display so that it only shows the text you are interested in. Text outside of the current ''restriction'' is hidden from view and inaccessible to editing commands.

+

Use {{CommandKeys|C-x n n|narrow-to-region}} to narrow the display to the current region. Use {{CommandKeys|C-x n w|widen}} to ''widen'' the display, making the entire buffer accessible again.

−

= Killing and yanking =

+

Note that narrowing can be confusing to new users, so the command <tt>narrow-to-region</tt> is disabled by default. If you have not explicitly enabled this command before trying to use it, you will be prompted to do so.

+

Narrowing can be considered an alternative to collapsing blocks of text (folding). Narrowing allows you to identify a block of text to edit, whereas folding allows you to identify a block of text to hide. Emacs has various ways to hide text (see [[#Selective Display]]). The key difference between hiding text and narrowing is that hidden text remains editable: you can still delete a block of text that has been collapsed from view. With a narrowing restriction, only the active text can be modified.

−

= Region =

+

You can read more about narrowing and other ways to hide text in the Emacs manual:

+

* {{Manual|emacs|Narrowing|Narrowing}}

+

== Selective Display ==

−

= Fill =

+

Emacs provides a way to hide lines of text indented more than a given number of columns:

This can be useful to hide "details" and get an overview of a file that uses indentation in some meaningful way (like most programming langauges). Note that the hidden text remains editable; see [[#Narrowing]] for a safer way to edit a specific portion of a buffer.

−

= Case-fold =

+

There are a variety of other ways to hide text in an Emacs buffer, such as [[Outline]] and [[Hideshow]] modes.

Contents

When you use [C-x C-f] to invoke command find-file, Emacs opens the file you request, and puts its contents into
a buffer with the same name as the file. Instead of thinking that you are editing a file, think that you are editing
text in a buffer. When you save the buffer, the file is updated to reflect your edits.

Buffers can also contain text that doesn't come from a file. When you use [C-x C-b] to get a list of buffers,
that list is itself in a buffer, called *Buffer List*, and that buffer is not associated with any file.

By convention, buffers whose names start with an asterisk (`*') are not associated with files (but that doesn't
mean you can't save them in files). If they have unsaved changes when you exit Emacs, these buffers are killed without
your being asking for confirmation.

Buffers whose names start with a space are invisible to many operations. These are generally
internal buffers that you don't want to see. Their names normally don't appear in the buffer list or as
completion candidates when you switch buffers using [C-x b].

Buffers are shown in windows. You can have more than one window showing the same buffer. [C-x 2]
splits the current window, creating two windows, both showing the same buffer.

In Emacs terminology, a "window" is a container in which a buffer is displayed. This may be confusing at first; if so, think "pane" whenever you see "window" in an Emacs context until you get used to it.

A new Emacs frame contains one window. This window can be split in to multiple windows using:

In Emacs terminology, a "frame" is what most window managers (Windows, OSX, GNOME, KDE, etc.) would call a "window".

It will typically have a title bar and some buttons to iconify (minimize), maximize / restore, and close the frame. To
see an example, open up a second frame from your running Emacs instance with [C-x 5 2] (or M-x make-frame-command). You can close frames with [C-x 5 0] (or M-x delete-frame), though this
will not close the last frame that is open.

To be completely correct, frames can be created when Emacs is running in terminal mode too, not just in a windowing system. They don't provide the same visual cues but otherwise work the same.

The active cursor shows the location at which editing commands will
take effect, which is called "point". Many Emacs commands move
point to different places in the buffer; for example, you can place
point by clicking mouse button 1 (normally the left button) at the
desired location.

If you use a block cursor, the cursor appears to be on a
character, but you should think of point as between two characters;
it points before the character that appears under the cursor. For
example, if your text looks like `frob' with the cursor over the `b',
then point is between the `o' and the `b'. If you insert the character
`!' at that position, the result is `fro!b', with point between the `!'
and the `b'. Thus, the cursor remains over the `b', as before.

Sometimes people speak of "the cursor" when they mean "point," or
speak of commands that move point as "cursor motion" commands.

Many Emacs commands operate on an arbitrary contiguous part of the
current buffer. To specify the text for such a command to operate on,
you set "the mark" at one end of it, and move point to the other end.
The text between point and the mark is called "the region". The region
always extends between point and the mark, no matter which one comes
earlier in the text; each time you move point, the region changes.

In Emacs, "killing" means erasing text and copying it into the "kill
ring". "Yanking" means bringing text from the kill ring back into the
buffer. (Some applications use the terms "cutting" and "pasting" for
similar operations.) The kill ring is so-named because it can be
visualized as a set of blocks of text arranged in a ring, which you can
access in cyclic order.

Emacs can display text in several different styles, which are called faces. Each face can specify various face attributes, such as the font, height, weight and slant, the foreground and background color, and underlining or overlining. A face does not have to specify all of these attributes; often it inherits most of them from another face.

On a text-only terminal, not all face attributes are meaningful. Some text-only terminals support inverse video, bold, and underline attributes; some support colors. Text-only terminals generally do not support changing the height, width or font.

Most major modes assign faces to the text automatically through the work of Font Lock mode. See Font Lock, for more information about Font Lock mode and syntactic highlighting. You can print the current buffer with the highlighting that appears on your screen using the command M-x ps-print-buffer-with-faces.

Emacs can adapt its behaviour to the specific type of text edited in a buffer. The set of specific Emacs customizations for a particular type of text is called a "major mode". Each buffer has exactly one major mode depending on its content type (but see MuMaMo for a way to relax this constraint).

Major modes can change the meaning of some keys, define syntax highlighing or indentation rules, and install new key bindings (usually beginning with [C-c]) for mode-specific commands. Emacs ships with a wide range of major modes, falling into three main categories:

In Emacs filling text means breaking it in to lines of a given maximum width. You can enable automatic filling with M-x auto-fill-mode, or fill a specific block of text using something like [M-q] (or M-x fill-paragraph).

Note that fill commands add hard line breaks to the text. This is different from what might be called "word wrap" (or "line wrap") in other tools, where the text is wrapped at the edge of the current display and re-flowed if the window is resized. Emacs provides this sort of wrapping as well, see #Screen Lines

Emacs provides several ways to deal with text lines that extend horizontally beyond the size of the current window. These are display features: they change the screen lines shown in the window without modifying the logical lines of the actual text.

By default, Emacs wraps a long line of text at the edge of the window and shows the remaining text in continuation lines.

Visual Line mode provides what is commonly called "word wrap": long lines are wrapped at the edge of the window without breaking in the middle of a word. Try M-x visual-line-mode.

Line truncation means that text beyond the edge of the display is simply not shown, i.e. the line is cut off. Try M-x toggle-truncate-lines.

These display options can affect how some editing and movement commands work. Refer to the documentation for details. To reformat text with hard line breaks, see #Fill.

You can read more about the various ways of visualizing long lines in the Emacs manual:

Sometimes you want to work on just a portion of the current buffer and ignore the rest. Emacs provides commands to narrow the display so that it only shows the text you are interested in. Text outside of the current restriction is hidden from view and inaccessible to editing commands.

Use [C-x n n] (or M-x narrow-to-region) to narrow the display to the current region. Use [C-x n w] (or M-x widen) to widen the display, making the entire buffer accessible again.

Note that narrowing can be confusing to new users, so the command narrow-to-region is disabled by default. If you have not explicitly enabled this command before trying to use it, you will be prompted to do so.

Narrowing can be considered an alternative to collapsing blocks of text (folding). Narrowing allows you to identify a block of text to edit, whereas folding allows you to identify a block of text to hide. Emacs has various ways to hide text (see #Selective Display). The key difference between hiding text and narrowing is that hidden text remains editable: you can still delete a block of text that has been collapsed from view. With a narrowing restriction, only the active text can be modified.

You can read more about narrowing and other ways to hide text in the Emacs manual:

Emacs provides a way to hide lines of text indented more than a given number of columns:
M-x set-selective-display, bound to [C-x $] by default.

This can be useful to hide "details" and get an overview of a file that uses indentation in some meaningful way (like most programming langauges). Note that the hidden text remains editable; see #Narrowing for a safer way to edit a specific portion of a buffer.

There are a variety of other ways to hide text in an Emacs buffer, such as Outline and Hideshow modes.