Reputation: 3420
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.
Upvotes: 54
Views: 62406
Reputation: 1002
Since C-x h moves the point, and I frequently need to yank afterwards anyways, I bound the following to a keyboard short:
(lambda () (interactive) (kill-new (buffer-string)))
Upvotes: 0
Reputation: 1720
Copying and selecting are related, but distinct, actions. A file and a buffer are also related, but distinct.
To copy a buffer, consider using jac.el. It handles both the "copying" and dealing with modes.
Upvotes: 0
Reputation: 4604
I use CUA, so I didn't like mark-whole-buffer
because it doesn't use a temporary region.
After much messing about, I finally achieved this using a keyboard macro saved to a function:
kmacro-name-last-macro
to name the macroinsert-kbd-macro
to script it outC-a
Upvotes: 0
Reputation: 2943
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:
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
).
Upvotes: 99