Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 157 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Whenever I copy code from a Stack Overflow post and try to paste it into Visual Studio or Notepad, all the carriage returns are lost and I have to go through and fix everything. Is there a proper way to do this so the carriage returns are maintained?


This bug is with Internet Explorer (7 and 8). It seems to work fine in Firefox and Chrome.

share|improve this question
sux, there should indeed be a "Copy code" link above each snippet like in all normal dev sites. – Shimmy Aug 25 '09 at 2:10
Apparently this is a regression, as this happens again. I remember it being fixed for some time previously but currently it is broken again. So how do we label this? status-to-be-fixed-again? – Joey Nov 25 '10 at 14:09
@Joey - I added "vote-to-reopen" I hope this is the right way to do it, also it seems someone reported on the regression, maybe voting up on it will also help… – Eran Medan Mar 27 '11 at 2:10
Doesn't format properly with IE9 either – StuTheDog Mar 27 '11 at 22:04

See here:

Why doesn't IE7 copy <pre><code> blocks to the clipboard correctly?

Also I believe this is on the Google code prettify guys' radar now, as I saw multiple tickets on it. It is easier for them to fix!

Update: the latest version of Prettify was deployed a few days ago; I verified that I can copy and paste from Internet Explorer in the sample post demonstrating the original issue fine. Kudos to Mike Samuel at Google for getting this fix in!

share|improve this answer
FYI: there's a user-submitted fix for this issue on the Google Code site. See I tried the fix by exporting the HTML of a SO page and including the fixed prettify.js after all your scripts, and it worked great in IE8 wihtout hosing FF3.5. For the first time I could copy SO code out of IE without having a Word window standing by. :-) I assume you'll be waiting for the official release from the google guys before fixing this on SO? – Justin Grant Oct 31 '09 at 18:20
Hi Jeff - @mikesamuel (the project lead of prettify) has released a fix for this problem. Download =, Change Log = Any idea when/if SO will be picking up the fix? – Justin Grant Dec 27 '09 at 19:02
we deployed the latest prettify a few days ago, so we should have it now -- unless the fix was Christmas Day or something? :) – Jeff Atwood Dec 27 '09 at 22:56

I agree that this is annoying. My workaround is to click "edit" and copy the code out of the text editor there, but this doesn't work so well if you're under 2k rep.

Note: I'm on IE7 most of the time. I don't know if this is a problem on other browsers.

share|improve this answer

The work around is copying it to Microsoft Word, then copying it to Notepad. Yes, it is Internet Explorer.

share|improve this answer
This works with IE8 and Word 2007 on XP. – tharen Feb 7 '12 at 22:17

Verified this in IE8 on Windows7 as well. IE6 on Windows XP SP2 does not appear to be affected.

share|improve this answer

I have the same problem with IE8. I made a pasting test in C#. If I use the command

string s = System.Windows.Forms.Clipboard.GetText();

s contains no CR and no LF, just spaces (" ") in the positions where the line breaks should be.


string s = System.Windows.Forms.Clipboard.GetText(TextDataFormat.Html);

however, I get some HTML code within which code examples from stackoverflow are hardly recognizable. Probably MS-Word decodes this HTML code, but VS and other editors fail to do so.

share|improve this answer

You must log in to answer this question.

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