Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"
share|improve this question
A space is valid character so surely it is part of the comment not just after the end of the line? – Mark Feb 1 '13 at 17:29
I made an edit to try to clarify, let me know if it's still unclear – DilithiumMatrix Feb 1 '13 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 '13 at 0:55
Cmd-c to copy; Cmd-v to paste. what is the kill-ring? – DilithiumMatrix Feb 7 '13 at 20:00
@halloleo ESC-w does not copy material selected with the mouse on my system. – DilithiumMatrix Feb 8 '13 at 3:12

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.