Questions tagged [copy-paste]

is about the editor operations cut, copy, and paste as they apply to Emacs. In Emacs, cut is called "kill" and paste is called "yank" (but Emacs enhances the standard cut and paste behavior).

Filter by
Sorted by
Tagged with
32
votes
10answers
6k views

Kill or copy current line with minimal keystrokes

I do C-a C-k C-k to kill the entire line point is on. If I want to copy the line instead of killing it, I can hit C-/ C-/ right after typing the sequence above. Alternatively, I can do C-a C-SPC C-...
25
votes
2answers
3k views

Add operating system clipboard to kill ring

Often I find myself copying a code snippet into my operating system's clipboard from the internet. Then, I take the following simple steps: Switch to my Emacs window Find the place where I want to ...
20
votes
7answers
13k views

Copy text from Emacs to OS X clipboard

When I run Emacs in a text terminal instead of the normal GUI mode, I can copy in Emacs by activating the start of a region with C-SPC, and then select what I want, and then do M-w. Is there any way ...
19
votes
1answer
3k views

Emacs doesn't paste in Evil's Visual mode with every OS clipboard

Setup: GUI version GNU Emacs 25.0.50.1 (x86_64-w64-mingw32) of 2015-07-25 on KAEL Compiled from EmacsW64. Package Evil, using the latest version of Evil from MELPA Windows 7 x64 bit. Situation: ...
12
votes
1answer
4k views

Spacemacs: paste into minibuffer

Is there a way to paste something into the minibuffer? For example if I want to eval-expression and paste something in there neiter C-v or (obviously p) will work? There has to be a way.
11
votes
1answer
1k views

Org mode - Parsing rich HTML directly when pasting?

Currently, for notetaking tools like Evernote and Quiver, I can directly copy HTML content from my favorite browser and then paste them into the app, with all the formatting + link preserved. However ...
9
votes
6answers
2k views

Simple ways to copy/paste files and directories between dired buffers

Is there a simple M-w C-y approach to copy paste files and directories between two dired buffers? I mean marking some items (files and buffer) by m then copying them by M-w (or another shortcut), ...
9
votes
2answers
554 views

How to change octal sequences into utf-8 text

When I copy non-ascii text from Windows and paste into Emacs, it shows up as an octal sequence. For example, if I paste ä into Emacs it shows up as \344. I could type C-q 344 to get the ä back in ...
8
votes
4answers
479 views

Fastest way to move code block to specific line

Say you have code on lines 4, 5, 6. Then you want to move this block of code to starting point line 9 while also deleting lines 4, 5, 6. What's the fastest way, i.e. least amount of key strokes, to ...
8
votes
2answers
3k views

How to access os clipboard using Emacs + Evil

How can i yank to/from windows clipboard when using: Windows 7 (x64) GNU Emacs 24.4.1 (x64) Evil 1.0.9 and having (setq x-select-enable-clipboard nil) in my .emacs? (I put this line there because i ...
7
votes
4answers
2k views

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 ...
7
votes
5answers
2k views

How to paste text that had been copied (alt-w) prior to my latest paste (ctrl-y)?

Once I have selected some text I use Alt-w to copy the region and then use ctrl-y to paste it. Is there a way to paste something I have selected and copied with Alt-w prior to my latest paste?
7
votes
3answers
931 views

Copy region from emacs without newlines

I would like to be able to easily select a region of text from Emacs and then paste it into another app or browser - with all the extra fill-paragraph newlines removed so that the paragraph display in ...
7
votes
1answer
114 views

How can I copy and paste characters displayed with compose-region?

I use several modes that display Unicode characters in my code without changing the underlying file. For example, in Haskell mode, the following code: foo :: forall a. Eq a => a -> a -> a ...
6
votes
4answers
389 views

Copy all file names that match regexp

In a dired buffer of a directory, how do I copy the file names of all files matching [tT]ypolog[yi]? Getting them from an elisp list format, \n separated format or otherwise into a python list format ...
6
votes
2answers
2k views

How to auto copy when a region is selected?

Chrome browser has an excellent extension called autocopy, which copies text whenever some text is selected/highlighted. To copy a region in emacs, I have to select the region and then press M-w to ...
6
votes
2answers
532 views

Evil-emacs: how to select last pasted text (like gv)?

How do I visually select the last pasted text with evil-emacs? gv reselects the last visual selection. I'd like a function/snippet that does the same for my last pasted text.
5
votes
2answers
638 views

Copy text as rectangle

This is the block of text that I intend to copy as rectangle (without the line numbers). 1. ALM_KRmet_DCDO_RPMP_START 2. ALM_KRmet_DCDO_RPMP_STOP 3. ALM_KRmet_DIDC_RPMP_TRIP 4. ...
5
votes
3answers
2k views

How to select (and copy) a column of an org table *without* rectangle selection?

It seems to me that the normal way to copy a column of an org table is by rectangle selection (see here). That is, first the column is selected by marking all of it by hand, and then it is copied with ...
5
votes
1answer
215 views

Inadvertent paste when correcting spelling mistakes using flyspell

When I click with the middle mouse button that usually inserts the primary selection at the point where I clicked. However, the same button opens flyspell's context menu when I click on a misspelled ...
5
votes
1answer
350 views

Handling text files with mixed encodings

I created a text file by copying its different parts from different sources (webpages, other text files, pdf files) into gedit and saved it to the file. I wonder if that is the reason why I may have ...
5
votes
1answer
931 views

Character encoding when copying some text from somewhere to Emacs and saving to a file

Suppose I copy some text from a source (e.g. a webpage, a text file opened in an editor such as gedit or emacs) to a buffer in emacs, and then save the buffer to a text file. When I copy the text ...
5
votes
2answers
739 views

How do I cut and paste effectively between applications while using EXWM?

For example, I am trying to copy the URL line from Firefox into an org mode buffer. The usual cut and paste keys for Firefox (C-c C-v) do not work, and neither does (M-w C-y). To copy from Firefox (...
5
votes
1answer
3k views

Copy and paste to system clipboard in tmux

I have the following code in my init.el (xclip-mode +1) (setq x-select-enable-clipboard t x-select-enable-primary t x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING) x-stretch-...
5
votes
1answer
240 views

Pasting text doesn't work properly in evil-/web-mode

In certain situations Emacs doesn't properly paste text. Apparently this only happens if the current buffer isn't saved and both web-mode and evil-mode are loaded. I was able to reproduce this ...
5
votes
2answers
274 views

Alternative shortcuts to copy the character

To copy the character at point usually I do Shift-<right> M-w. I am wondering what are the alternative ways to do this action using only the Emacs standard keybindings (maybe with minimal ...
4
votes
2answers
445 views

How to get contents of current line?

I want to get contents of the current line(the line with cursor) for my function. What command allows me to achieve this?
4
votes
3answers
436 views

Only allow kill-ring-save if there is highlighted text

I would like to wrap kill-ring-save in order to only execute kill-ring-save if text has been highlighted - same as in most text editors. Sometimes I accidentally hit copy instead of paste and then my ...
4
votes
3answers
182 views

Copy a column of uneven width that ends with a specific character

I have a data file that looks as follows ALGO = Fast EDIFF = 6.7e-05 ENCUT = 520 IBRION = 2 ICHARG = 1 ISIF = 2 ISMEAR = 0 ISPIN = 2 I'm interested in copying the first column of uneven width but ...
4
votes
2answers
3k views

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 ...
4
votes
2answers
2k views

Copy and paste between Emacs in an X terminal and other X applications

I am running Emacs in Gnome-terminal on Ubuntu. The way I know to copy and paste between emacs and other applications is by Ctrl+C and Ctrl+V, which I think is by the terminal emulator. A problem ...
4
votes
1answer
391 views

How can I paste my password when pushing?

Instead of memorizing all of my passwords, I use a password manager to store them for me. Currently, since I use Magit for most Git purposes, I need to go through several steps in order to push: P P ...
4
votes
2answers
515 views

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

I use the brilliant answer from my previous question to copy selected regions of text from Emacs onto my system pasteboard (i.e. the OSX clipboard). But some functions (e.g. gist-buffer) push output ...
4
votes
2answers
452 views

Copy/paste between SSH terminal Emacs and macOS

Suppose you are working in macOS, and you decide to SSH into a Linux box and fire up terminal Emacs. How do you copy and paste between macOS and your SSH terminal-Emacs? Copying and pasting between ...
4
votes
1answer
246 views

Copy text as it is rendered by Emacs

I have Emacs doing a bunch of smart things to display text for me. In particular, some text has the invisible property set, and I'm running adaptive-wrap with <!-- adaptive-wrap-extra-indent: 3 --&...
4
votes
0answers
54 views

Copy buffer content verbatim

Emacs uses overlays / prettify-symbols-mode / etc which modify how data is displayed to user. I like to copy visible content as I see it. For example I aligned columns in CSV file with M-x csv-align-...
3
votes
4answers
2k views

A quick way to copy the word before the cursor

By M-backspace (or by M-x backward-kill-word), I can remove the word before the cursor. Is there a built-in equivalent of this command for copying instead of deleting? Obviously one can do M-x ...
3
votes
2answers
194 views

How can I yank images from Emacs?

I want to copy images from Emacs to macOS clipboard. I have tried selecting them and yanking, which hasn't worked. Google also didn't have a solution.
3
votes
2answers
911 views

How to turn off bracketed paste mode?

I saw that bracketed paste mode is automatically enabled in Emacs 25.1 running in a terminal. But I want to disable this mode. Because this mode adds text like 200~ 201~ to pasted text, bracketed ...
3
votes
1answer
135 views

Almost working smoothly attempt to get terminal Emacs to copy to clipboard

I'm running this emacs GNU Emacs 25.2.2 (x86_64-pc-linux-gnu) of 2017-09-22, modified by Debian directly in a Gnome terminal by calling emacs, which is actually a link to /etc/alternatives/emacs. ...
3
votes
2answers
249 views

Pasting Text from Clipboard - why ^M instead of linebreaks?

I'm using some VBA scripts which copy Text in MS Outlook from an e-mail message and send it to the clipboard. If I then paste the clipboard content with Ctrl-Y in Emacs 24.5.1 in Windows 7, the ...
3
votes
3answers
138 views

How to paste-then-copy?

I'm not sure whether anyone has ever implemented what I'm looking for, but maybe I'm just using the wrong terms to search for it. What I want to achieve is essentially a reverse copy and paste: I'm ...
3
votes
1answer
129 views

Copy non-printable characters as displayed by Emacs

Very similar to this question: Copy text as it is rendered by Emacs but what I need is to coy the ^M, ^E and so on characters as they are displayed. (Otherwise the text in clipboard gets truncated).
3
votes
0answers
89 views

copy to clipboard without overwriting kill ring

I'm looking for a way to copy to clipboard from emacs without passing through the kill-ring, moving the marker or using the mouse. If I use x-select-enable-primary and x-select-enable-clipboard, I can ...
3
votes
0answers
707 views

Emacs takes a very long time to read/save to the clipboard

Sometimes emacs takes a very long time (+ 30 seconds) to read from or save to the system (Linux) clipboard. The entire emacs session hangs while it does this and I can't cancel it with C-g or ESC ESC ...
2
votes
2answers
134 views

Is it possible to get the start and end points in the buffer in which text is pasted?

Like if you have a buffer containing hel! and paste in lo world after the third letter you get 4 and 11 respectively? Emacs has many state variables, are there any that could help me in this case?
2
votes
2answers
6k views

copy from shell and paste in terminal-emacs

How can I copy from the command line and paste in Emacs in terminal mode? If I select the text with the mouse and paste it from the clipboard with the third button (the wheel) it is OK. But if I try ...
2
votes
4answers
1k views

Copy multiple lines?

The command kill-whole-line does just what it says. With a prefix argument, it allows me to kill multiple lines at the same time. How can I get the same functionality, but with copying instead of ...
2
votes
1answer
597 views

How to set copy to C-c in Emacs?

I have tried using Cua mode (via adding (cua-mode t) to my ~/.emacs file) but it doesn't seem to set the copy keybinding to Ctrl-c. See for example this screenshot showing my Edit menu: I have tried ...
2
votes
1answer
364 views

How to avoid term turn line wrap into line break for long output

When the output in term is longer than the frame it will wrap the line. But when I copy and paste the output, I found the output will break under the wrap point, because it treat it as line break. How ...