12. Emacs Editing

Emacs is a powerful and extensible text editor widely used on Linux and other Unix-like systems. This beginner Emacs guide will introduce you to some fundamental editing commands. In Emacs terminology, C- refers to the Ctrl key, and M- refers to the Meta key, which is usually the Alt key.

While standard navigation keys like Home, End, and the arrow keys work as expected, Emacs offers more efficient commands for moving through your text, which Emacs holds in a "buffer". Mastering Emacs navigation is a key step in becoming proficient.

Here are some essential Emacs commands for moving the cursor:

C-up arrow: move up one paragraph
C-down arrow: move down one paragraph
C-left arrow: move one word left
C-right arrow: move one word right
M->: move to the end of the buffer

Cutting and Pasting

In Emacs, cutting is called "killing" and pasting is called "yanking". To perform these actions, you first need to select a region of text.

To begin selecting text, move your cursor to the start of the desired region and press C-space. This sets the "mark". Then, use any navigation commands to move the cursor to the end of the region you want to select. The area between the mark and your current cursor position will be highlighted.

Once you have selected a region, you can use the following commands:

C-w: kill (cut) the selected region
C-y: yank (paste) the last killed text

These basic commands form the foundation of editing in the Emacs text editor.

Sign in to save your learning progress

Sign in

Exercises

The best way to learn Emacs commands is through practice. Open a new text file using emacs my_practice_file.txt and try out the navigation, selection, cutting, and pasting commands covered in this lesson. Get comfortable moving around the buffer and manipulating text.

Quiz

How do you move to the end of the buffer? Please answer using only the key combination format shown in the lesson (e.g., C-w). The answer is case-sensitive.