Warm tip: This article is reproduced from serverfault.com, please click

How to copy/select a whole file or buffer in Emacs?

发布于 2014-03-20 20:44:21

Is there any command to select the whole file contents in Emacs?

For example, Control+a selects whole contents of a file in Notepad, Notepad++, etc.

I can select whole contents using the mouse, but it's inconvenient for large files. I found the basic Emacs commands here and here, but could not find what I am looking for.

Questioner
Sajib Mahmood
Viewed
11
keelerm 2014-03-22 00:51:29

C-x h will select the entire buffer.

You can search for help within Emacs using the built-in help system.

C-h f will look for help for specific functions. In this case, you could have searched for whole-buffer to find mark-whole-buffer.

Other help commands of interest would be:

  • C-h m to show available commands for the current modes
  • C-h v for help related to variables
  • C-h k to find which functions keys are bound to
  • C-h w to see which key bindings are defined for a given function
  • C-h ? to see which other options are available.

Note that C-x h will only highlight all the text. To actually copy the selected text, you must use C-w for cut (kill-region) or M-w for copy (kill-ring-save).