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

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).

Leave a Comment