What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 127 Stack Exchange communities.

Possible Duplicate:
Prettified code copied in Internet Explorer pastes without line breaks

When I copy code from Stack Overflow into Visual Studio 2010, all the line feeds seem to be gone. I need to copy code into Word and then copy from Word to Visual Studio. Can Stack Overflow reformat these Code boxes to work with Visual Studio?

For example, the code fragment at C# Encrypt an XML File, when it is copied and pasted into Visual Studio, goes in as one big line.

Here is the code from the link I included. It is short and simple. I actually am using this fragment:

key = new RijndaelManaged(); byte[] passwordBytes = Encoding.UTF8.GetBytes("Password1234"); //password here byte[] saltBytes = Encoding.UTF8.GetBytes("Salt"); // salt here (another string) PasswordDeriveBytes p = new PasswordDeriveBytes(passwordBytes, saltBytes); // sizes are devided by 8 because [ 1 byte = 8 bits ] key.IV = p.GetBytes(key.BlockSize / 8); key.Key = p.GetBytes(key.KeySize / 8);

This is how code goes into Visual Studio. As you can see, the linebreaks are mangled.

If fixing this is low priority, just say so; but don't insult my intelligence by telling me to use another browser or that copy/paste is foolish.

When used, someone has to go through this code and sort it all out. Sometimes we are looking at a lot of lines. Stack Overflow provides a great place to share/learn. But why should I have to type things like this in order to use the knowledge?

share|improve this question

migrated from stackoverflow.com Sep 16 '11 at 19:24

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Shog9 Nov 5 '11 at 16:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

add comment

2 Answers

Because it is incredibly stupid foolish unwise to copypaste code from the internets into your code.

Code you found online should be read, understood, and then reproduced from that understanding.

However, your immediate problem is an IE issue, nothing to do with the implementation of these sites.

share|improve this answer
4  
So I should read, understand and reproduce linux and all OSS? I think you're being a lot unrealistic here - sometimes copying and pasting is exactly the right way to go. –  Roddy Sep 16 '11 at 20:23
1  
@Roddy: So you're all k with copying code you found online and pasting it into your own? –  Won't Sep 16 '11 at 20:28
    
@Won't ಠ_ಠ Sometimes you need to copy-paste in case you are typing something wrong or can't deduce the exact character being used. Especially if characters are similar (i.e. . versus ,) –  Foo Bah Sep 16 '11 at 22:57
    
I copy code from SO questions into LinqPad all the time. –  CodesInChaos Nov 5 '11 at 13:12
6  
This might be true, but it's a horrible answer, as it more or less implies that the site does this on purpose to discourage. Especially from a diamond. –  Rosinante Nov 5 '11 at 13:40
    
@Rosinante you make too many assumptions. Also, if having a diamond means that I can no longer have an opinion then I resign. –  Won't Nov 5 '11 at 16:34
4  
Oh, please. You can have all the opinions you like. I'll tell you what, I'll make a trivial edit to your answer to address my complaint, and remove my downvote. –  Rosinante Nov 5 '11 at 16:39
add comment

This problem is caused by IE, not VS. You might want to consider using a different browser.

share|improve this answer
add comment