I want to be able to kill selected text and yank it to the bottom of the buffer from which it was killed.
How do I do this efficiently, meaning not with C-k, moving point to end of buffer, C-y?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI don't think there's anything built-in that's more efficient than this:
C-w
M->
(i.e., end-of-buffer
)C-y
C-u <space> <space>
If you do this a lot, you can wrap these operations into a function:
(defun my-yank-at-end (beg end)
(interactive "r")
(save-excursion
(let ((target (kill-region beg end )))
(end-of-buffer)
(insert "\n")
(yank))))
This function assumes you've got an active selection before you call it. It also adds a newline before it yanks the selection.
I'd rather use standard keyboard short-cuts or the customised solution of @Taylor above, but for completenes sake here are two out of the box Emacs ways:
append-to-file: Save your buffer (so it's only working for buffers with an underlying file) and select a region, then M-x a-t-f
and specifying your-file will ad the region is at the end of your-file. (To see this change in the current buffer you have to revert the buffer, which will happen after you start editing and Emacs warns you that your buffer is not updated and you press r
.)
append-to-buffer: Interactively this appends the region only behind the current point
. So M-x a-t-b
and specifying your-buffer doesn't work exactly for the use case above but for appending to other buffers it's very convenient.
r
the buffer will be reverted, I updated my answer accordingly, thanks.
Oct 29, 2016 at 17:32