Emacs editing environment, Part 3: Advanced Emacs text operations

Get going with this famous open source editor

This tutorial, the third in a series, builds on what you've learned by taking you through a tour of some of the more advanced Emacs features for text operations. You get a hands-on demonstration of advanced editing techniques, including how to perform a recursive edit, mark and use rectangles of text, and handle complex selection techniques using the kill ring and the secondary selection.

Before you start

Learn what to expect from this tutorial, and how to get the most out of it.

About this series

The Emacs editing environment is a favorite of UNIX® developers. It's known around the world as the king of editors, but many users find it has a bit of a learning curve. The Emacs environment doesn't seem intuitive at first glance, and it doesn't work like other editors and word processors. But learning Emacs doesn't have to be difficult. Once you get going, you'll see how intuitive it is and become more comfortable with it after each use. This tutorial series shows you the way, taking you from the basics of Emacs, such as its features, philosophy, key-command layout, and methods for editing text, through many of its powerful editing features.

After completing this series, you'll be able to comfortably use Emacs for everyday editing, be well on your way to Emacs proficiency, and have a good feel for many of the advanced capabilities of Emacs.

About this tutorial

This is the third installment in a series of tutorials on learning Emacs; it builds on what you learned in the first two tutorials by taking you on a tour of some of the more advanced Emacs features for text operations. You get a hands-on demonstration of advanced editing techniques, including how to perform a recursive edit and mark and use rectangles of text, and you learn about complex selection techniques involving use of the kill ring and the secondary selection.

Objectives

The primary objective of this tutorial is to take users who already have a basic understanding of Emacs text-editing techniques and show you how to build on those basic and intermediate techniques to perform advanced editing tasks, such as making secondary selections, entering recursive edits, and using rectangles. After working through this tutorial, you should be familiar with all these topics and be able to use them in your editing sessions.

Prerequisites

This tutorial builds on several concepts introduced in the first two installments in this series (see Resources), so you should take them before attempting this tutorial. The practice file from the first installment is used in the examples here.

The special Emacs notation for representing keystrokes, which is used in this tutorial and throughout the entire series, is described in the introduction of the first tutorial of the series, "Emacs editing environment, Part 1: The basics of Emacs" (see Resources).

Although this tutorial is written for all levels of UNIX expertise, it's helpful if you have at least a rudimentary understanding of the UNIX filesystem:

  • Files
  • Directories
  • Permissions
  • Filesystem hierarchy

System requirements

This tutorial requires a user account on any UNIX-based system that has a recent copy of Emacs installed.

There are several varieties of Emacs; the original and most popular is GNU Emacs, which is published online by the GNU Project (see Resources).

You should have a recent copy of GNU Emacs -- one that is at version 20 or greater. Versions 20 and 21 are the most commonly available, and development snapshots of version 22 are also available. This tutorial works with any of these versions for Emacs. If your system is running something older, it's time to upgrade.

To know what version of Emacs you have running, use the GNU-style --version flag:

$ emacs --version
GNU Emacs 22.0.91.1
Copyright (C) 2006 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.
$

Modify the command execution of Emacs

As you begin to look at some of the advanced techniques for text editing with Emacs, the first thing to learn is how to alter regular command execution in Emacs, including those commands you already know. The techniques that follow fill in a few blanks from material you learned in the first two tutorials in this series, showing you a few techniques related to altering commands before, during, and after they're run.

Specify a digit prefix

You know that the universal argument precedes a command with a number, as described in the first tutorial in this series (see Resources). But there's another way to do it that can be quicker when you just want to specify a single digit: Use the digit-argument function, which you type with the Meta key in conjunction with a single digit: M-5 C-n.

The preceding command runs the next-line function, C-n, five times.

To specify a single digit, use digit-argument. This way is quicker than using the universal argument command (in this example, it would be C-u 5 C-n) because it requires pressing one less key.

Try it now on the practice file from the first tutorial in this series, which you saved to a file named practice.b:

  1. Start Emacs with the file:

    $ emacs practice.b
  2. Move the cursor down three lines by stepping it with:
    M-3 C-n
  3. Move the cursor backward five characters:
    M-- M-5 C-f

    Notice that a negative number makes a given command work in reverse. (You can get the same result with M-5 C-b.)

  4. Move to the end of the buffer by typing:

    M-9 M-9 M-9 C-f

    Notice that you can specify longer, multidigit numbers by combining several Meta keystrokes in a row -- this is even quicker than using the universal argument.

  5. Insert several blank lines: Type M-4 followed by the Enter key.

  6. Indent eight spaces: Type M-8 followed by the spacebar.

  7. Insert three dashes with M-3 -.

Your buffer should now look like the one in Figure 1.

Figure 1. Emacs editing with the digit-argument function
Emacs editing with the digit-argument function

Repeat the last command

The repeat function is useful for intensive editing. As its name implies, it repeats the last command you typed.

Try running a command and repeating it:

  1. Type C-b to move the cursor back one character.
  2. Repeat it once with C-x z.

You can also repeat a command repeatedly -- do this by typing a z again to repeat the command a second time; keep typing z to repeat it again.

Try it:

  1. Type z to move the cursor back one character.
  2. Type z multiple times to move the cursor back several characters.
  3. Type C-f to move the cursor forward one character.
  4. Type C-x z to repeat the forward-char once, and then type z to repeat until Emacs beeps to indicate that you've reached the end of the buffer.

If you precede the repeat command with a number -- either given with the Meta key or through the universal argument function -- you repeat the last command that many times.

Try it by typing C-b M-5 M-0 C-x z to move the cursor back 50 characters.

Perform a recursive edit

You learned about the various Emacs commands for searching and replacing text in the second tutorial in this series, "Emacs editing environment, Part 2: Emacs modes and editing features" (see Resources). As described in that tutorial, the replace-string function replaces one given string with another; query-replace (bound to M-%) does the same thing, but it prompts you before making each replacement, letting you decide whether a given replacement should be made.

When you run query-replace, one of the options available while making a given replacement is the recursive edit, which is a special Emacs feature that lets you suspend the current editing task so that you can interactively edit the buffer while the task waits in the background. To indicate that you're in a recursive edit, the current mode in the mode line is surrounded by square brackets. Exit the recursive edit by typing C-M-c, the exit-recursive-edit function; when you do so, the square brackets are removed from the mode line, and you're back to the original editing task or context from before you entered the recursive edit.

You can enter a recursive edit at any time by running the recursive-edit function. As the name implies, you can nest any number of recursive edits; each time you do, the current mode in the mode line is enclosed by a new set of brackets.

In the case of query-replace, you type C-r at the query prompt to enter a recursive edit. This lets you stop before a particular replacement is made so that you can edit the buffer; when you exit the recursive edit, you're brought back to the replacement operation.

Try it now:

  1. Type M-% to run the query-replace function.
  2. Answer the queries in the minibuffer:
    • Query replace: o
    • Query replace o with: a
  3. At the first replacement, get into the recursive edit by typing C-r when queried:
    • Query replacing o with a: (? for help) C-r
  4. Move to the end of the buffer by typing M-> and then type William Bloke after the three dashes.
  5. Type C-M-c to exit the recursive edit.
  6. Type n to decline replacement of the first match.
  7. The next match found is the o in Bloke that you typed after the query-replace function ran; type y to replace it.

When this function exits, the final portion of your buffer should look like Figure 2, and Emacs should report in the minibuffer that it replaced one occurrence of the given string.

Figure 2. After a recursive edit during an Emacs query replace
After a recursive edit during an Emacs query replace

Rectangles

Did you ever wish you could select a box of text from a document for copying, killing, or yanking purposes? You can. In Emacs, a selection of text specified by any two opposite of its four corners is called a rectangle; the following sections show you how to use rectangles effectively.

Mark a rectangle

All you have to do to specify a rectangle is set the mark in any one of its four imaginary corners and then move point to the opposite corner. When you do so, the imaginary box of text framed by the two corners you've selected is the current rectangle.

When you run one of the following rectangle commands, it works on the text you've selected. All of the rectangle commands of Emacs begin with C-x r, and they're explained in the following sections.

Erase a rectangle

There are a few ways to get rid of text you've marked as a rectangle. Although all the functions described here erase the current rectangle, each of them has a different effect.

Kill a rectangle

Use the kill-rectangle function, C-x r k, to kill the current rectangle. It works like the regular kill-line function that you're familiar with: It removes all the characters in the rectangle and doesn't replace them with anything. Any characters to the right of the rectangle automatically move to the left.

This function saves the contents of the rectangle in a special rectangle kill area, not the normal kill ring (see Use the kill ring).

Try it now:

  1. Move point to the beginning of the stanza that begins with What the hammer, and type C-space to set the mark.
  2. Move point to just before the word terrors to specify a rectangle of four lines (with, incidentally, three words on each line).
  3. Kill the rectangle you selected: Type C-x r k.

The rectangle you selected is gone. Notice how all the text to the right of it moves over to fill the rectangle's place.

Delete a rectangle

To delete the characters in a rectangle you've marked without saving them, use delete-rectangle, which is bound to C-x r d. This command deletes the area of the rectangle, so the effect looks just the same as if you killed the rectangle (as just described); the difference is that you aren't able to yank back the text you killed.

(However, as you learned back in the first tutorial, you can always undo an action you just performed. If you type C-_ right after you delete or kill a rectangle, the original text of the rectangle is restored.)

Clear a rectangle

Both of the two commands for erasing rectangles that have just been described remove the entire space that the rectangle occupied. But you can also clear it, replacing the entire area with space characters by running the clear-rectangle function, which is bound to C-x r c.

Try it:

  1. Move point to just before the word dare in the line On what wings dare he aspire?, and set the mark by typing C-space.
  2. To specify a small rectangle consisting of the word dare on two lines, move point to just after the word dare in the line below it.
  3. Type C-x r c to clear the rectangle you just defined.

Notice that point moves to the lower-left corner of the rectangle.

Open a rectangle

Finally, you can open a rectangle -- use the rectangle to specify an area where whitespace should be added. To do this, mark a rectangle, and then run the open-rectangle function, C-x r o. Doing so fills the entire rectangle with space characters and pushes all text in the rectangle to the right.

Try it now:

  1. Move point to the top of the buffer and set the mark by typing C-space.
  2. Move point to right after the Co in Could in the bottom stanza.
  3. Open the rectangle by typing C-x r o.

Yank a rectangle

To yank the contents of the last-killed rectangle at point, run yank-rectangle, which is bound to C-x r y. This command inserts, at point, the last rectangle that was killed. When the insertion occurs, all existing text on all lines of the rectangle is pushed to the right.

Try it:

  1. Move point to the beginning of the stanza whose text contains what the chain: Type M-< M-1 M-5 C-n M-2 C-f.
  2. Type C-x r y to yank the rectangle.

Notice that the small rectangle you just cleared wasn't the one that was yanked; when you clear a rectangle, it's not saved -- only rectangles that are killed are saved, and you can only yank the last rectangle that was killed.

Also notice that point moved to just after the lower-right corner of the rectangle, and the minibuffer reports that the mark has been set. When you yank a rectangle, the mark is set to the upper-left corner of the rectangle you yanked.

To replace a rectangle with whitespace but save its original contents so that you can yank it later, first kill it, then yank it, and then clear it:

  1. Set the mark just before the first Did he in the second-to-last stanza by typing M-< M-2 M-2 C-n M-2 C-f C-space.
  2. Type M-6 C-f C-n to move point to just after the he in the next line.
  3. Type C-x r k to kill the rectangle.
  4. Type C-p to move point to the upper-left corner of the rectangle you just killed.
  5. Yank it with C-x r y.
  6. Clear it with C-x r c.

At this point, you can yank the rectangle somewhere else. The original location of the rectangle is now full of whitespace.

Try it:

  1. Move point up to just after the word wings by typing M-1 M-6 C-p M-1 M-4 C-f.
  2. Yank the rectangle with C-x r y.

Notice that point moves to the lower-right corner of the rectangle you just yanked. The mark has been set in the upper-left corner of the rectangle, as reported in the minibuffer.

Table of rectangle commands

Table 1 lists the various Emacs rectangle commands you just learned, giving their function names and describing their meanings.

Table 1. Emacs commands for using rectangles
KeyFunctionDescription
C-spaceset-mark-commandMarks one corner of a rectangle (point marks the opposite corner).
C-x r kkill-rectangleKills the current rectangle and saves it in a special rectangle buffer.
C-x r ddelete-rectangleDeletes the current rectangle and doesn't save it for yanking.
C-x r cclear-rectangleClears the current rectangle, replacing the entire area with whitespace.
C-x r oopen-rectangleOpens the current rectangle, filling the entire area with whitespace and moving all text from the rectangle to the right.
C-x r yyank-rectangleYanks the contents of the last-killed rectangle at point, moving all existing text to the right.

Manipulate the mark

Setting the mark and making selections are important, related Emacs concepts that you learned about in the first tutorial in this series (see Resources). But there's more to it than that, and this section describes some advanced editing techniques related to these topics.

Move to the mark

You know that C-space, the set-mark-command function, sets the mark at point. But when you continue editing, it's sometimes useful to know exactly where in the buffer the mark has been set -- and it's also handy to go back to the mark, if you set it at a point and want to refer to it for some reason. Emacs currently doesn't have a way to visualize where the mark is set, but there are ways to move point to the mark, which solves both problems.

You can do this a few ways. One is to precede C-space with the universal argument C-u command. Doing so changes the meaning of C-space -- instead of setting the mark, it moves to the mark.

The last thing you did in your practice buffer was yank a rectangle (see the preceding section), so point moved to the lower-right corner of the rectangle and the mark was set at the upper-right corner. Try moving to the mark now by typing: C-u C-space.

This is a good, fast technique, but it's not convenient if, after you move to the mark, you want to return back to where point was -- that position is lost. But there's another way to move to the mark that remembers the position of point and is useful for such occasions. Use the exchange-point-and-mark function, which is bound to C-x C-x. It works the way it sounds: It moves point to the mark but, at the same time, it sets a new mark at point.

Try it now:

  1. Type M-< C-space to set the mark at the top of the buffer.
  2. Type M-5 C-n to move away from the mark.
  3. Exchange point and mark: Type C-x C-x.
  4. To move back to the last location of point -- and to set the mark back at the top of the buffer -- run the command again: Type C-x C-x.
  5. The mark is set to the top of the buffer again. If you run this command again without setting a new mark, you go back to the top of the buffer no matter where you've moved point. Try it by moving point and then running this command again: Type M-9 C-f C-x C-x.

You can use this command as a quick and powerful way to "see" where the mark is set, by typing it twice: The first time you type C-x C-x you move the cursor to the mark, but you also set the mark at the point where you were. The second time you type C-x C-x you set the mark back where it was, and you move to the point where you were in the beginning.

Mark special parts of a buffer

Emacs has a few special functions that mark certain types of textual units. They're worth knowing about and are described here.

All of these mark commands can be preceded with digits to modify the number of units they mark and their position, either to the right of the current point (positive digits) or to the left (negative digits).

Mark words

The mark-word function marks from point to the end of the current word and is bound to M-@ (press and hold the Meta key and type the @ character).

It's not useful for quickly cutting out a word -- you should still use M-d to do that, as you learned in a previous tutorial -- but it's a good command for marking a single word to perform some other operation on it, such as case conversion with the upcase-region and downcase-region functions, which convert all the text in the region to uppercase and lowercase characters, respectively.

Try it:

  1. Move to the last line in the buffer, right before the W: Type M-> M-b M-b.
  2. Type M-2 M-@ to mark the two words to the right of point. (If you hadn't just moved to the left of these words, you could accomplish the same thing with M-- M-2 M-@.)
  3. Run the function to convert the region to all uppercase letters: Type M-x upcase-region and press Enter.
  4. Notice that a new window opens, telling you that the upcase-region function is disabled; this is because it can be confusing to new users. You're well past that now, so type y to enable it for this session. Then, if you like, type y again when you're prompted for whether you'd like to enable it for future sessions, too.

Mark paragraphs

The mark-paragraph function, M-h, marks the current paragraph as the region. Point can be anywhere in the paragraph when you type this. This function sets the mark to the end of the paragraph and moves point to just before the paragraph.

Try marking a paragraph:

  1. Move to the last stanza with M-5 C-p, which moves point to the second-to-last word on the last line.
  2. Type M-h to select this paragraph.
  3. Notice that point moves to the blank line just before the stanza. The mark is set to the line immediately preceding the stanza -- type C-x C-x to verify that.

Mark whole buffers

To mark the entire buffer at once, run the mark-whole-buffer function, C-x h.

Try it now: C-x h C-w C-y marks the entire buffer as the region, kills the region (so the entire buffer is killed), and then yanks it.

This technique is good for copying an existing buffer in its entirety into another buffer. Do this by marking the buffer as the region and then typing M-w to run the kill-ring-save function. Then, you can paste it somewhere else, even in another buffer.

Use the mark ring

You just learned that typing C-u C-space returns to the last mark that was set (see "Move to the mark"). But Emacs remembers more than the last mark -- it remembers the last 16 marks you set, and it keeps them in a special place called the mark ring.

When you type C-u C-space multiple times, Emacs cycles through those 16 locations in the mark ring. After you type this command 16 times, Emacs loops around to the first mark in the ring.

Each buffer has its own mark ring that keeps the last 16 marks set in that particular buffer.

Try typing C-u C-space multiple times to cycle through some of the last marks set in your practice buffer.

Set a transient mark

As long as a mark is set somewhere in the buffer, there is a region -- as you've learned, the current region is the area between the mark and the current point -- but the region is invisible, so you can't normally see it. One way you can see the region is when you first select it by dragging with the mouse -- and that only lasts until you press a key.

But you can make the region visible by running the transient-mark-mode function, which is a toggle. When this minor mode is set, the region is highlighted whenever you set the mark, and it remains highlighted while you adjust it, such as by using the cursor motion keys. As soon as you type another key that changes the buffer and doesn't have to do with the region, such as when you type a regular alphanumeric character to insert it at point (or if you type C-g), the highlighting disappears and the region is cleared, although the mark still remains set.

If you set the mark again or if you type a command that has to do with the region -- such as exchanging point and mark -- then the region is set and it is highlighted in the buffer again.

Try it now:

  1. Type M-x transient-mark-mode to enable this mode.
  2. Move to the end of the buffer and set the mark: Type M-> C-space.
  3. Move the cursor up by typing C-p a few times and watch the mark grow.
  4. Move to the top of the buffer and insert an empty space: Type M-< C-o. Notice that the region is no longer highlighted.
  5. Type C-w to kill the region and notice how nothing is killed -- instead, Emacs beeps and reports in the minibuffer, "The mark is not active now."
  6. But you still have a mark set -- type C-x C-x to demonstrate this, and watch how the region is quickly highlighted again.

Your Emacs session should look like Figure 3.

Figure 3. A visible region in Transient mark mode
A visible region in Transient mark mode

Notice that this is one minor mode that doesn't write in the mode line when it's activated. Type M-x transient-mark-mode to disable it.

Use the secondary selection

Back in the first tutorial of this series, you learned how to set the mark and manipulate the region, and you also learned how to use the mouse to make selections. But when you're using X, there's another way to select and kill text with the mouse, without using the mark and point or even setting the mark or moving point at all. This is by using the secondary selection, which is a contiguous region of selected text whose ends aren't delineated by the mark and the current point. You make a secondary selection by holding down the Meta key while you use the mouse to make a selection.

You'll notice that the secondary selection is highlighted in a different color than the normal X selection.

Try making a secondary selection now:

  1. Press and hold the Meta key.
  2. Click B1 at the beginning of the first stanza and drag it to the end, and then let go of both the Meta key and the mouse button.

When you do this, point isn't moved from where it was.

You can also make a secondary selection without dragging. To do so, press and hold the Meta key, click B1 at the beginning, click B3 at the end, and release the Meta key.

There are a few more shortcuts for selecting words and lines as the secondary selection, and they're analogous to the same mouse operations used to make a regular selection: Press and hold the Meta key and then double-click the first button (M-B1-B1) when the mouse pointer is on a word to select the entire word, and press and hold the Meta key while you triple-click somewhere on a line (M-B1-B1-B1) to select the entire line.

Try it now: Press and hold the Meta key and then double-click the word Tiger in one of the places it appears in the buffer. Notice, again, that point doesn't budge from its position.

To paste the secondary selection, press and hold the Meta key and then click B2 at the point in the buffer where you want to paste it. When you do this, the cursor moves to the end of the selection you paste. You can also paste it in another X client window.

Try it by clicking B1 between WILLIAM and BLAKE, pressing the spacebar to insert an extra space; then press and hold the Meta key and click B2 to paste the secondary selection there.

Table of mark and selection commands

Table 2 provides a summary of the advanced mark and selection commands that you just learned. It gives their function name, if applicable.

Table 2. Advanced Emacs mark and selection commands
KeyFunctionDescription
C-u C-space Moves to the previous mark in the mark ring.
C-x C-xexchange-point-and-markSwaps the location of point and the mark.
M-@mark-wordMarks all text from point to the end of the current word.
M-hmark-paragraphMarks the current paragraph, regardless of the location of point.
 transient-mark-modeToggles Transient Mark mode.
 mark-whole-bufferMarks the entire buffer, regardless of the location of point.
M-B1 Sets the beginning of a secondary selection; drag to make a secondary selection.
M-B3 Sets the end of a secondary selection.
M-B1-B1 Marks a word as the secondary selection.
M-B1-B1-B1 Marks a line as the secondary selection.

Advanced kill and yank commands

You already know about killing and yanking text, which were described in the first tutorial in this series (see Resources), but there's more to it than those basic operations. This section describes some advanced techniques.

Advanced kill commands

You know that C-k kills everything from point to the end of the line, but a few other interesting kill commands work on other parts of a buffer.

Kill more than the current line

If you precede C-k with a numeric argument -- using either the Meta key (as described in "Specify a digit prefix") or with the universal argument -- you kill that many lines.

If you precede C-k with a zero, you kill all the text from point to the beginning of the line.

Try killing everything to the left of point on the current line: Type M-0 C-k.

Now, when you yank, you bring back the beginning of the line. Try it: C-y.

You can also go backward. A negative argument kills that many lines backward, beginning with everything on the current line before point. For example, C-u -5 C-k kills from point to the beginning of the line and five lines before it.

Kill sentences

Use the kill-sentence function, M-k, to kill all the text from point to the end of the current sentence.

Try it out:

  1. Move point to the line that begins with In what distant: Type M-< M-6 C-n M-2 C-f.
  2. Type M-k to kill the sentence.

Like C-k, this command starts its kill from point -- and it can also take a numeric argument. So, M-0 M-k kills from point to the beginning of the sentence.

Zap to a character

The zap-to-char function, which is bound to M-z, is useful for deleting a range of characters from the cursor up to and including a particular character. Run it by typing M-z and then giving the character to zap to.

Try it now:

  1. Type M-z.
  2. Type D to zap everything up to and including the first D character.

As with the other commands described here when preceded with a numeric argument, this function zaps to that number of the given character, either forward from point (a positive integer) or backward (a negative integer).

Try zapping everything from point to the fifth e character behind it: Type M-- M-5 M-z e.

Use the kill ring

Just as there's a mark ring to save the marks that are set (as described in Use the mark ring), there's also a kill ring, which saves the text that's killed each time you kill it. Each time you kill some text, it's saved in a slot in the kill ring. The only exception is a rectangle -- the last rectangle you kill is saved in its own special place outside of the kill ring (see Rectangles). Every buffer's kill ring has 30 slots in it by default.

When you type C-y to yank the last text you killed, you actually yank from the top of the kill ring. To go back one slot further in the kill ring, type M-y. Doing so replaces the text you just yanked with the previous text in the kill ring. Each time you type M-y again, you go back further in the kill ring.

You can also precede the usual C-y with a numeric argument to yank that particular position in the kill ring, with the most recent being the lowest number in the ring -- so C-u 1 C-y is the same as M-1 C-y, which is the same as a simple C-y.

Try yanking the third item in the kill ring at point: Type M-3 C-y.

But C-u C-y, with no numeric arguments, has a special meaning. Normally, C-y yanks the text at the top entry in the kill ring at point, and then point moves to the end of the yanked text. But with C-u C-y, point remains at the beginning of the text you yank. This is good for editing the text you're about to yank.

Try it now by yanking text at the beginning of the line: Type C-a C-u C-y.

You can look at the contents of the kill ring by viewing the kill-ring variable. Try it: Type C-h v kill-ring.

This command opens a new window showing the contents of the kill ring. Type C-x 1 to close the window.

Table of kill and yank commands

Table 3 provides a summary of the advanced kill and yank commands described in this section.

Table 3. Advanced Emacs kill and yank commands
KeyFunctionDescription
integer C-kkill-lineKills integer number of lines. If 0, kills from point to the beginning of the line; if negative, kills in reverse.
M-kkill-sentenceKills from point to the end of the sentence.
M-zzap-to-charZaps all text from point to the specified character.
M-yyank-popMoves to the next slot in the kill ring.
integer C-yyankYanks the specified slot in the kill ring.

Summary

Wrap-up

This ends the third tutorial in a series on using Emacs. As you probably realize by now, Emacs is so full of features and functionality -- even some that you've probably never heard of in any other editor or application -- that it earns its name as the king of editors.

There are more Emacs concepts and features to learn but, having mastered some of its more advanced text operations, you should be a confident Emacs user now and ready to use it in your everyday work. When you do, you'll find it a productive and rewarding experience.

Resources

Learn

Get products and technologies

  • GNU Project Web site: Download a free copy of the latest GNU Emacs for your OS and architecture free of charge.
  • IBM trial software: Build your next development project with software for download directly from developerWorks.

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into AIX and Unix on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=AIX and UNIX
ArticleID=216415
ArticleTitle=Emacs editing environment, Part 3: Advanced Emacs text operations
publish-date=05012007