Emacs copy a paste line with comment adds extra space / line 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                                                  
              | &lt;-- end on first pasted line is now about here
someInt = 10
someString = "stringy"
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.