I work in emacs in a termal tab, and instead of using the built in copy and paste shortcut commands I generally just highlight (with the mouse) to copy and paste. This works fine for normal code/text, but when the section being copied includes a comment, the pasted text includes extra white-space after the end of the comment line - and it's a pain to go to every comment line and delete that whitespace (which wraps onto a newline). See example below:

Is there anyway to stop this behavior?

For example, in a python code, highlighting from the initial # to the end of "stringy":

# Some comment line
someInt = 10
someString = "stringy"

is copied and pasted as:

# Some comment line                                                  
              | <-- end on first pasted line is now about here
someInt = 10
someString = "stringy"
  • A space is valid character so surely it is part of the comment not just after the end of the line?
    – mmmmmm
    Feb 1, 2013 at 17:29
  • I made an edit to try to clarify, let me know if it's still unclear Feb 1, 2013 at 18:14
  • I cannot reproduce this: when highlight text with the mouse, then hit ESC-w for copying, then go where ever I want to go and paste the kill-ring it works fine. What key combination do you use for copying?
    – halloleo
    Feb 7, 2013 at 0:55
  • Cmd-c to copy; Cmd-v to paste. what is the kill-ring? Feb 7, 2013 at 20:00
  • @halloleo ESC-w does not copy material selected with the mouse on my system. Feb 8, 2013 at 3:12

1 Answer 1


I guess you problem arises to an extend from continuing lines which get copied with the physical line break on screen. One way to avoid this and get proper mouse highlighting in Emacs, is running it as a separate GUI app. I installed GNU Emacs for Mac OSX and it runs perfectly with mouse selection capabilities: You can select with the mouse and continuing lines get copied as single lines as you want it.

GNU Emacs for Mac OSX will pick up your normal .emacs configuration and if you do not like the GUI elements like the toolbar you can hide them on startup in the variable default-frame-alist.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .