When we copy content from Stack Overflow, it provides the whole content as a single line. It does not provide the content as it shows formatted on the screen.

Or is there any way to select the content as formatted?


Let me explain the specific scenario. You can copy the HTML code from here. I have copied the content in Notepad.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">   <xsl:template match="/">     <HTML>       <HEAD>         <STYLE type="text/css"> TABLE{table-layout: automatic; width:100%} .tblHeader{background-color:RGB(192,192,192);font-weight:bold} .row1{background-color:RGB(204,204,255)} .row2{background-color:RGB(153,204,255)} </STYLE>       </HEAD>       <BODY>         <TABLE border="1">            <THEAD>             <tr class="tblHeader">               <xsl:for-each select="*/*[1]/*">                 <td>                   <xsl:value-of select="."/>                 </td>               </xsl:for-each>             </tr>           </THEAD>            <TBODY>             <xsl:for-each select="ClientArray/Client">               <TR>                  <xsl:for-each select="*">                   <TD>                     <xsl:value-of select="."/>                   </TD>                 </xsl:for-each>                </TR>             </xsl:for-each>            </TBODY>         </TABLE>       </BODY>     </HTML>    </xsl:template> </xsl:stylesheet> 

Another scenario:

If you copy the code and paste it into Visual Studio, it pastes all the codes in a single line. When it is one or two lines, it is OK.

Please let me know if I am doing anything wrong.


Not Working #1

  • OS: Window 7
  • Application: Visual Studio 3.5, Notepad
  • Browser: Internet Explorer 8

Not Working #2

  • OS: Window Vista
  • Application: Visual Studio 3.5, Notepad
  • Browser: Internet Explorer 8

I have tested the same thing in another environment, and it is working properly on the same machine. The only difference is the browser, which is Firefox (working).

It means the issue is with Internet Explorer.

Please share your thoughts.

  • 3
    Works fine for me (tm)...Browser? OS? – Time Traveling Bobby Jun 11 '12 at 13:07
  • 1
    You can not expect an answer without more information. There are many possible system configurations, you can not expect us to guess what yours is. – caesay Jun 11 '12 at 16:18
  • 3
    Sounds like another regression of Prettified code copied in Internet Explorer pastes without line breaks (I'm tempted to say it's a dupe, but we don't know if you're indeed using IE, and the other one is status completed...) – Arjan Jun 11 '12 at 16:26
  • I have update the question for more clarity. – Arun Singh Jun 12 '12 at 5:38
  • Works perfectly for me (into Kate), I get the formatting exactly as it originally was. Have you checked your settings in Visual Studio to see if it's not doing some kind of weird stripping of newlines? – Latty Jun 12 '12 at 9:45
  • May i know, what is the reason for downvote? – Arun Singh Jun 13 '12 at 4:56
  • Maybe because @Alex someone made the word update H U G E, rather than removing it altogether... ;-) – Arjan Jun 13 '12 at 17:16
  • Hey, you were the one who included it in the first place. I just made it prettier :) – Alex Lockwood Jun 13 '12 at 17:38
  • Ah, now you're mixing names too. Sorry @Alex, I didn't realize you need glasses ;-) (er, note the smiley) – Arjan Jun 13 '12 at 17:48
  • Oops, I mixed up the names lol. Well, IDK about @Arjan but I still use "edit" in my posts... I don't think that is any reason to downvote question either, especially from a new user. – Alex Lockwood Jun 13 '12 at 17:51
  • (As an aside: the downvote was not mine. And I assume the first downvote was for lack of any detail, but that has meanwhile been E D I T E D into the post ;-)) – Arjan Jun 13 '12 at 17:52
  • Thanks Alex, If it is an issue with IE8, What should be the next step? Please suggest. – Arun Singh Jun 13 '12 at 17:55
  • The copy (from SO) and paste (in MS Notepad and VS) works for me just fine on Win 7 IE 9. If you are on windows 7, upgrade to IE version-9. – vulcan raven Jul 30 '12 at 8:05

I can confirm the issues you have, because on my PC there is the same behaviour, if you do the following (using Internet Explorer 7 or 8), you can

reproduce the issue:

  1. Select StackOverflow.com code snippet
  2. Copy it via Ctrl+C
  3. Paste it into Visual Studio via Ctrl+V

After step 3., in the Visual Studio's editor, you lose the formatting of the code. The line breaks are gone.

While I believe this is a bug (most likely of IE, but it could be the code inside of the StackOverflow website as well), I found a

simple workaround:

  1. Select StackOverflow.com code snippet and copy it via Ctrl+C
  2. Open WORDPAD (by typing wordpad in the start menu's command window)
  3. Paste it into the empty WORDPAD window via Ctrl+V
  4. Select the code in WORDPAD via Ctrl+A, then copy it via Ctrl+C
  5. Paste it into Visual Studio via Ctrl+V

Somehow WORDPAD writes the information correctly into the clipboard, so it is transferred later correctly into Visual Studio (important: don't use NOTEPAD, because NOTEPAD can't handle RTF).

Note that Microsoft's MSDN website provides a link button to copy code snippets into the clipboard correctly (for example: click on any of the "copy" links on the page of this link). I'd suggest that this would be a nice feature request for the web site developers of stackoverflow to fix this.


My copy paste works:


All I did was copy and paste your question into Notepad++ .

  • 1
    Looks like you've got word wrap set to true there. – ChrisF Jun 11 '12 at 13:06
  • @ChrisF even so, it copied it with the correct line spacing etc, I did not put in the new line. – amanaP lanaC A nalP A naM A Jun 11 '12 at 13:07
  • 1
    I wasn't saying you did. Just that if you had work wrap off the first paragraph would have been on "one long line". – ChrisF Jun 11 '12 at 13:09
  • @ChrisF haha true, but that all depends on your screen resolution, editor, and many many other factors – amanaP lanaC A nalP A naM A Jun 11 '12 at 13:10
  • 1
    I have tried the same with word wrap true and false. In both cases data is not formatted. – Arun Singh Jun 12 '12 at 5:40

You must log in to answer this question.

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