Questions tagged [kill-ring]

The kill ring is a global list of blocks of text that were previously copied or moved from buffers.

The kill ring is a list of blocks of text that were previously killed.

Killing moves text from a buffer to the kill ring. Text can also be copied from a buffer to the kill ring, without removing it from the buffer.

There is only one kill ring, shared by all buffers, so you can kill text in one buffer and yank it in another buffer. This is a common way to move text from one buffer to another.

The maximum number of entries in the kill ring is controlled by option kill-ring-max (which you can customize). If you make a new kill when this limit has been reached, Emacs makes room by deleting the oldest entry in the kill ring.

The actual contents of the kill ring are stored in a variable named kill-ring; you can view the entire contents of the kill ring using C-h v kill-ring. See also function kill-new, which adds a killed or copied string to the kill ring.

Reference: https://www.gnu.org/software/emacs/manual/html_node/emacs/Kill-Ring.html

73 questions
9
votes
2 answers

How do I filter kill-ring contents?

Is it possible to prevent kill-ring from storing whitespaces/empty lines? Right now after I do a couple of changes and then go to browse-kill-ring I often see something like this: ------- ------- merchant_uuid: "some_uuid" ------- it…
Ignacy Moryc
  • 185
  • 6
4
votes
0 answers

What is the distinction between copying text between a region BEG/END, and copying a region?

I was trying to add a custom functionality when using C-u before the "copying" command or kill-ring-save. So I jumped into the source code (pasted below for convenience) to examine what it originally does. For brevity I will use the default binding…
Kaushal Modi
  • 25,651
  • 4
  • 80
  • 183
4
votes
1 answer

Modification of kill-ring-save to copy current word/line/whole buffer/ if no region is selected

I would like to write a function which on the first execution behaves like the regular kill-ring-save if some region is selected on the first execution copies the current word if no region is selected, on the second execution copies the current…
Name
  • 7,849
  • 4
  • 41
  • 87
3
votes
1 answer

Is there any way to edit the kill-ring?

Are there any tools to directly edit the kill-ring? If I open xah-show-kill-ring, I'm tempted to edit the contents directly.
Jason Hunter
  • 709
  • 4
  • 10
1
vote
1 answer

How to clear the `kill-ring`?

I really like counsel-yank-pop. I like it so much that I have changed my keybindings so that C-y is bounded to counsel-yank-pop. However, after a while the kill-ring tends to become a big mess. I would like to "clear" it. It is already possible to…
Pedro Delfino
  • 1,489
  • 3
  • 16
1
vote
3 answers

How to display list of previous copies/kills (`M-w` or `C-w`)?

C-n C-y retrieves the n-last call to C-w, I think. Is there a way to show all that were saved?
user19777
1
vote
2 answers

Cutting only after I paste

Is there a way to cut text in such a way that it is only removed from the buffer when I paste it somewhere else? I find myself often losing the text I had cut because, after I cut, I find out I need to do something else before I can paste the text…
Ivan Perez
  • 400
  • 2
  • 15
1
vote
0 answers

Copy buffer absolute file path to the system clipboard

How can i copy the absolute path of the current open buffer to the system clipboard (i.e. ctrl + shift + v) and not (ctrl + y) There are many solutions available for such copy, 1 and 2 but all of them doesn't work outside the emacs application.
Saravana
  • 2,071
  • 13
  • 32
0
votes
1 answer

How can I prevent kill-visual-line from appending kills to the kill-ring?

As described in the manual, each kill command pushes a new entry onto the kill ring. However, two or more kill commands in a row combine their text into a single entry, so that a single C-y yanks all the text as a unit, just as it was before it was…
Jason Hunter
  • 709
  • 4
  • 10
0
votes
2 answers

Copy current line if there is no active region

I wrote this custom function to copy the entire line, if no mark is set (defun sk-copy-ops (beg end) (interactive "r") (if mark-active (kill-ring-save beg end) (kill-ring-save (line-beginning-position) (line-end-position)))) I am seeing two…
Saravana
  • 2,071
  • 13
  • 32