15 votes

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

If yanking the path into the current buffer is not acceptable, use C-u C-c C-k, which invokes helm-kill-selection-and-quit. From the documentation of helm-kill-selection-and-quit: Store display ...
  • 9,002
12 votes
Accepted

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

In general, there's nothing wrong with using commands as part of elisp code. Those functions which are only meant for interactive use will (or should) warn you about that. See next-line for instance. ...
  • 22.5k
11 votes
Accepted

How to copy text without losing selection?

The best solution is using C-x C-x to reactivate the mark. But if you want to really keep the selection you can use: (defun copy-keep-highlight (beg end) (interactive "r") (prog1 (kill-ring-save ...
  • 3,067
10 votes
Accepted

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

Try C-c TAB when you have the file highlighted. This will yank the path into the current buffer, which might be an undesired side effect, but as long as you do helm-find-files from the buffer you want ...
  • 4,635
10 votes
Accepted

Backspace without adding to kill ring

According to the documentation: <C-delete> runs the command kill-word (found in global-map), which is an interactive compiled Lisp function in ‘simple.el’. It is bound to <C-delete&...
  • 6,111
9 votes

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

This is from 12.2.2 Yanking Earlier Kills: ‘M-y’ can take a numeric argument, which tells it how many entries to advance the “last yank” pointer by. A negative argument moves the pointer toward ...
8 votes
Accepted

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

Simply use the kill ring. In evil, your simplest option is to use evil-paste-pop, bound by default to C-p. Here's the docstring: Replace the just-yanked stretch of killed text with a different ...
  • 31.4k
8 votes

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

The suggestion in @gongqj's answer changes the behavior of paste so that cut text (via d) no longer gets pasted. This does not seem like what you want given your comment: Ideally pasted over text ...
  • 181
7 votes

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

@Malabarba's answer looks like the simplest and most elegant solution. However, if you do this enough that it warrants its own function, you can also adapt comment-kill to delete without modifying ...
  • 31.4k
7 votes
Accepted

how to move region to other window?

Your code is alright except that it is missing the mandatory arguments to the other-window command. From the function documentation (C-h f other-window RET), (other-window COUNT &optional ALL-...
  • 24.5k
7 votes
Accepted

How to copy killed rectangle to the kill ring

If I understood your question, your are looking to something like this: (defun youngfrog/copy-rectangle-to-kill-ring (start end) "Saves a rectangle to the normal kill ring. Not suitable for yank-...
  • 6,111
6 votes

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

The package https://github.com/Lindydancer/highlight2clipboard does exactly what you asked for. It use htmlize to create a HTML version of the text which it adds as an alternative paste text. (Note: ...
  • 5,865
6 votes

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

The htmlize package can do this. Install it with M-x package-install htmlize and you get access to the commands htmlize-region (htmlize-region BEG END) Convert the region to HTML, preserving colors ...
  • 12.3k
6 votes
Accepted

Kill a line deletes the line but leaves a blank newline character

From documentation: kill-whole-line is an interactive compiled Lisp function. It is bound to <C-S-backspace>. (kill-whole-line &optional ARG) Kill current line. With prefix ...
  • 6,111
6 votes
Accepted

kill-region deletes entire buffer content instead of selected text

As the comments suggest, eval-buffer manipulates the position of point, so that by the time you call kill-region, region-beginning and region-end are no longer what they were when you started. The ...
  • 20.7k
6 votes

how can I get Emacs kill-ring to behave like a simple clipboard buffer?

I want to simplify the kill-ring so that it behaves like a simple clipboard. I find it complex that the kill-ring contains multiple items. You can completely ignore the fact that the kill ring ...
  • 44.3k
6 votes
Accepted

how can I get Emacs kill-ring to behave like a simple clipboard buffer?

From the various comments so far, it sounds like you are in the process of learning about Emacs (welcome!). There are many things in Emacs that are unlike other editors, and as you go through the ...
  • 19.5k
5 votes

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

TL;DR: you can use clipmon available on MELPA, and turn on clipmon-mode. Note: the details below apply to X servers, but the package should work on any platform. How does the clipboard work ? ...
  • 3,416
5 votes

How to stop C-backspace or M-backspace from copying text?

If you look at what M-backspace calls using C-h <M-backspace> you see that it calls backward-kill-word that function simply calls kill-word with a negative argument. The kill-word function is ...
  • 1,255
5 votes
Accepted

Calc: copy only a value, not stack number

Just after posting this, I found a solution I'm surprised I didn't think of sooner: Hit backtick (calc-edit) to edit the stack value. Kill the line in the edit buffer with C-w (editing it first if ...
  • 835
5 votes
Accepted

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

After yank text1, the text is saved in both register " and 0: "" text1 "0 text1 "1 ... When paste with p, you actually got text1 from register ", at the same time, the killed text is saved in "...
  • 231
5 votes

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

You have a few options for this :- You can use counsel which provides with the command counsel-yank-pop which will show the list of all the yanked text and you can select anyone of them using ivy (...
5 votes
Accepted

Copying a rectangular selection to system clipboard

(defun copy-rectangle-to-system-clipboard (start end) "Like `copy-rectangle-as-kill', but also copy to system clipboard." (interactive "r") (call-interactively #'copy-rectangle-as-kill) (with-...
  • 13.8k
5 votes

How copy content of minibuffer to kill-ring?

Just like ordinary buffers, C-x h (mark-whole-buffer) then M-w (kill-ring-save).
  • 13.8k
4 votes
Accepted

how to push kill-ring contents onto system pasteboard (clipboard)?

The function x-select-text can be used to do this: Select TEXT, a string, according to the window system. On X, if `x-select-enable-clipboard' is non-nil, copy TEXT to the clipboard. If `x-select-...
  • 8,659
4 votes

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

expand-region or easy-kill or hydra might provide better idea on how to do one thing continuously, but here is a silly command which tries to do exactly what you want. (defvar my-kill-ring-save--...
  • 13.8k
4 votes

Backspace without adding to kill ring

Since Emacs 24, without any configuration, you can delete any text without adding it to the kill ring by selecting it and then pressing Backspace or Delete. When the mark is active, these keys delete ...
4 votes

Calc: copy only a value, not stack number

You can set mark and point, and save the region to the kill ring with kill-ring-save, which by default is bound to C-M-w in calc mode (instead of M-w as it is in most other modes).
4 votes
Accepted

How to send *shell* stdout directly to kill-ring?

Emacs Command Instead of select-and-copy manually, you can also write a command and let it do the work for you: ;; Adapted from `comint-delete-output' (defun comint-copy-output () "Copy all output ...
  • 13.8k

Only top scored, non community-wiki answers of a minimum length are eligible