Like, Control-A (select all) followed by delete?
7 Answers
How about using:
M-x erase-buffer
Which you could bind to whatever you want.

- 73,529
- 11
- 197
- 229
-
3I have this in my .emacs: `(global-set-key (kbd "C-x
") 'erase-buffer)` – Pål GD Nov 01 '15 at 15:49 -
2For new users, when `M-x erase buffer` is invoked for the first time you will receive a prompt explaining that it has been disabled but you can enable it . If unsure about exactly what this command does, I recommend running it with the `SPACE` option the first time to see what happens. – Nathan Feb 04 '16 at 18:07
C-x h + del
key clears the buffer
Note: This requires transient-mark-mode
to be enabled (which it is by default).

- 73,529
- 11
- 197
- 229

- 884
- 1
- 9
- 10
-
4This (or `M-x erase-buffer`) does not add the contents of the buffer to the kill ring, but `C-x h C-w` does, and `C-x h C-w` also works when transient mark mode is not enabled. – nisetama Jun 18 '16 at 06:42
Select all in Emacs is:
C-x h
(technically, that's mark-whole-buffer) and kill-region (to kill the marked region, which is now the entire buffer) is:
C-w
If you want to delete the region without copying it to the kill-ring, you can use
M-x delete-region
instead. If you do this alot, you'll want to bind delete-region to a key/key combo.

- 9,872
- 2
- 33
- 57
-
8The difference between this solution and M-x erase-buffer, is that this solution copies the deleted text into the kill-ring. That can be very annoying if one wants to delete a large file as copying a ton of text to the kill ring can be slow. This behavior is even more annoying if one is a user of browse-kill-ring.el – Noah Sussman Nov 28 '12 at 14:59
These macros build on the answers given above. To start using them paste them into your .emacs then restart emacs or (while in the .emacs buffer) type M-x eval-buffer.
(defun clear-buffer ()
"clear whole buffer add contents to the kill ring"
(interactive)
(kill-region (point-min) (point-max))
)
(defun clear-buffer-permenantly ()
"clear whole buffer, contents is not added to the kill ring"
(interactive)
(delete-region (point-min) (point-max))
)

- 11,480
- 9
- 70
- 91
-
1`erase-buffer` will clear the buffer regardless of narrowing. That may or may not be more desirable. – jpkotta Dec 10 '15 at 19:51
-
1`erase-buffer` does not add the contents of the buffer to the kill ring however. – nisetama Jun 18 '16 at 06:28
Old folks might like to call it hk rather than clear-buffer-permanently, and assign it to the nostalgic key sequence like so:
(define-key esc-map "\^[hk" 'hk)
That's the pre-Gnu TECO EMACS command to clear the buffer (ESC ESC wHole Kill).

- 51
- 1
- 2
Go to the begin of the buffer, go to the end (both set the mark), then cut:
M-< M-> C-w

- 7,332
- 2
- 33
- 42