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.

  • 4
    sux, there should indeed be a "Copy code" link above each snippet like in all normal dev sites. Commented Aug 25, 2009 at 2:10
  • 2
    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
    Commented Nov 25, 2010 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 meta.stackexchange.com/questions/83992/…
    – Eran Medan
    Commented Mar 27, 2011 at 2:10
  • Doesn't format properly with IE9 either
    – StuTheDog
    Commented Mar 27, 2011 at 22:04

6 Answers 6


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!

  • FYI: there's a user-submitted fix for this issue on the Google Code site. See code.google.com/p/google-code-prettify/issues/detail?id=71. 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? Commented Oct 31, 2009 at 18:20
  • Hi Jeff - @mikesamuel (the project lead of prettify) has released a fix for this problem. Download = code.google.com/p/google-code-prettify/downloads/list, Change Log = google-code-prettify.googlecode.com/svn/trunk/CHANGES.html. Any idea when/if SO will be picking up the fix? Commented Dec 27, 2009 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? :) Commented Dec 27, 2009 at 22:56

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

  • This works with IE8 and Word 2007 on XP.
    – tharen
    Commented Feb 7, 2012 at 22:17

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.


It seems to be back again: Prettified code copied in Internet Explorer pastes without line breaks (I agree)


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


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.

You must log in to answer this question.

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