Select All Text in Emacs

When working with Emacs, there are different instances when you need to select all the text in your buffer. Maybe you want to cut the entire text or paste it elsewhere. As a text editor, Emacs offers different ways to select all the text in your buffer. This guide focuses on the two main ways of selecting all in Emacs. Moreover, we will give the steps and commands on what to do after selecting all the text. For instance, we will see how to copy or cut the selected area. Let’s begin!

Two Ways on How to Select All Texts in Emacs

When you want to select all in Emacs, the goal is to mark a “region” that you want to select. In this case, the region is the entire text in your buffer. For instance, if you want to cut/delete all the text inside your buffer, selecting it all is the easiest option instead of deleting character by character. Let’s cover two methods of implementing the Emacs “select all”.

Method 1: Using the Keyboard Shortcuts

Like most things in Emacs, you can select all using the keyboard shortcuts. With this method, you must define the start and end area for the target region. Since our goal is to select all, the start mark is the start of the buffer and the end mark is the end of the buffer.

To mark the start of the buffer, ensure that your cursor position is at the start or where you want to start selecting from. Next, press the “C-space” or the “Ctrl + Space” keyboard shortcut to mark the start position. You will get an output that shows “Mark activated” to confirm that the start area has been marked.

The next step is to select the last mark which is the buffer’s end. Move the cursor to the end of the buffer using the “M ->” command which is the “Alt+Shift+ >” keyboard shortcut.

Doing so will select the marked region, similar to selecting everything inside your Emacs buffer.

You will notice how the background color will change to confirm the selected buffer region. You are now ready for the next task which is to cut the selected region or perform other formatting options.

Method 2: Using the “Mark-Whole-Buffer” Command

Suppose you feel that setting the start and end of the target region is such a hassle. There is an easy way out. For this second method, we will use the “mark-whole-buffer” command.

Open your buffer that contains the text that you want to select. To select it all, press the “C-x h” command which means pressing “Ctrl +x then h”. The region inside your buffer will be selected and the background color will change to confirm that you managed to select it.

You will get an output that shows “Mark set” which confirms that the target region has been selected.

Working on the Selected Region

We’ve seen the two methods that you can use to select all in Emacs. After selecting the region, there are different operations that you can perform. For instance, you can copy, cut, or paste the text. Let’s go through each of it.


You can only copy a selected item. To copy the selected region inside a buffer, ensure that you selected it using either of the methods that were covered earlier. Then, press the “M-w” command which is the “Alt + w” keyboard shortcut to copy the text.

Cutting the Text

You can delete all the selected text inside your buffer using the “cut” option. Select the region, then press the “C-w” command which is “Ctrl + w” and all the text/region will be deleted from your buffer.

Paste the Text

If you want to copy-paste the selected text, start by selecting it and copying it. Lastly, press the “C-y” command, the “Ctrl + y”, to paste the copied text where the cursor is. We pasted the text in our following example to duplicate it.


Emacs allows you to select all the text inside your buffer for different operations. Whether you want to copy or cut the text inside the buffer, this post has presented two methods to select all the contents inside your buffer by marking the region. Lastly, we provided three operations on what to do with the selected region including copying, cutting, and pasting the text.

About the author

Denis Kariuki

Denis is a Computer Scientist with a passion for Networking and Cyber Security. I love the terminal, and using Linux is a hobby. I am passionate about sharing tips and ideas about Linux and computing.