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

70 questions
14
votes
1 answer

How to copy text without losing selection?

When I copy some selected text (kill-ring-save with M-w), I automatically lose my selection. I have tried with Transient Mark Mode with no luck. (Note that I'm not using CUA Mode.)
NVaughan
  • 1,481
  • 12
  • 27
13
votes
2 answers

Function to delete all comments from a buffer, without moving them to kill ring

I need to be able to remove all comments from a buffer from elisp code. For now, I am using: (goto-char (point-min)) (comment-kill (count-lines (point-min) (point-max))) However, comment-kill is an interactive function, and its primary usage is to…
T. Verron
  • 4,233
  • 1
  • 22
  • 55
13
votes
4 answers

Backspace without adding to kill ring

Using Crtl+Backspace or Ctrl+Del adds the deleted text to the kill ring. How can I prevent this from happening? I do not need to have every single piece of text sent to the kill ring when it gets deleted. Side question: What's the purpose of this…
Daniel Hitzel
  • 507
  • 4
  • 13
12
votes
3 answers

How to copy killed rectangle to the kill ring

I frequently extract a rectangle of text from a buffer, but then find I want to yank the text as if it was not a rectangle. Is there a way to add the current killed rectangle to the kill ring? The GNU Emacs Manual has this to say: “Killing” a…
nispio
  • 8,175
  • 2
  • 35
  • 73
12
votes
4 answers

How do I yank and cycle backward through earlier killed text?

Emacs has this very handy kill-ring that can be cycled through after yanking, by pressing M-y repeatedly. Is there a way to switch the cycling direction? So I don not need to cycle through all when I actually want to get to the very first one?
stevosn
  • 291
  • 2
  • 8
11
votes
5 answers

Calc: copy only a value, not stack number

This seems so obvious that I feel sure that I've just missed something in the manual. I frequently do a calculation and then want to use that calculation elsewhere. But let's say my stack is currently: --- Emacs Calculator Mode --- 1: 42 . Any…
Trey
  • 865
  • 5
  • 20
11
votes
2 answers

How can I use Helm File Finder to copy a file path to a buffer?

Is there a way, in the buffer launched from helm-find-files, to copy a file path to the kill ring?
DJG
  • 213
  • 2
  • 5
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
9
votes
4 answers

In Evil mode, how can I prevent adding to the kill ring when I yank text, visual mode over other text, then paste over?

If I have text1 text2, I yank text1 with yw then I highlight text2 with vw and paste overwrite that text with p, my kill ring now has text2. I'd prefer if text2 wasn't added to my kill ring because next time I paste text, Emacs will paste text2…
irregular
  • 962
  • 1
  • 9
  • 21
9
votes
3 answers

How to push system clipboards to kill ring contents at real-time when I copy outside emacs?

I noticed that when I copy thing outside of Emacs, the thing does not appear to kill ring immediately except I yank it to Emacs. If I copy twice, only the last copy can be got by yank. Sometimes, I would like to push the copys from system…
Leu_Grady
  • 2,420
  • 1
  • 17
  • 27
7
votes
4 answers

How can I copy syntax highlighted code as RTF or HTML?

I'm using Emacs to write code samples that I later want to be able to paste into a MS-Word document, preserving the syntax highlighting. I understand that in order to do this I need to copy the text in either RTF or HTML format. Currently I'm just…
xlbloke
  • 71
  • 1
  • 3
6
votes
1 answer

how to move region to other window?

How can I automatically move selected to the other window? Trying to streamline my split-window workflow. Here's what I have so far. Doesn't work yet. (defun move-region-to-other-window (start end) "Move selected text to other window" …
incandescentman
  • 4,111
  • 16
  • 53
6
votes
2 answers

Evil: Is there a default register that does not get overwritten by later yanks to explicit registers?

I often use registers in evil, but I have a common use case that I cannot seem to resolve. I would like to have all copied text stored somewhere that does not get overwritten when I explicitly make another copy to a specific register. Here is an…
modulitos
  • 2,432
  • 1
  • 18
  • 36
4
votes
1 answer

How to copy output from ess to the kill ring?

Q: how can I automatically copy output from ess to the kill ring? Background I use ess to conduct statistical analysis. On occasion, I need to copy its raw output into another buffer (usually something like the raw output from xtable to a .tex…
Dan
  • 32,584
  • 6
  • 98
  • 168
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,203
  • 3
  • 74
  • 179
1
2 3 4 5