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

No matter what combinations or order of Ctrl+c, Ctrl+p, Ctrl+k, and the {} button I press, I cannot seem to copy formatted code from a question to my answer. Can somebody clue me in please?

Edit: I'm using IE8.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

I typically copy the markdown source directly, instead of copying the formatted text. If the post has been edited, click the "edited X minutes ago" link to get to the revision history, and then click "view source" to get to the source. If it hasn't been edited you have to go to the revision history manually; it's at http://stackoverflow.com/posts/POST_ID/revisions

share|improve this answer
    
Ok, this works, but it seems really round about. Is this the only way? –  ThomasMcLeod Jan 31 '11 at 3:18
    
@Thomas There's a feature request to add a link all the time. It's somewhat easier for 2k users, since they have an edit link they can use –  Michael Mrozek Jan 31 '11 at 3:20
3  
@mic anonymous users can edit now, if the post is older than 24 hours. registered users can always edit, though the edit must be approved. FYI. –  Jeff Atwood Jan 31 '11 at 3:36
    
@Jeff Oh, that's a good point; I guess everyone can just use the edit link then –  Michael Mrozek Jan 31 '11 at 4:10
    
@Jeff, I don't see how I can edit posts older than 24 hours without approval. –  ThomasMcLeod Jan 31 '11 at 4:10
2  
@Thomas You can't, but you can get to the edit page, which lets you copy the markdown –  Michael Mrozek Jan 31 '11 at 4:52
    
@Thomas Install the SEModifications user script, it will add a history link to all posts, and does other things too. Also see the other Stack Exchange Scripts. –  nyuszika7h Jan 31 '11 at 16:56
    
@Nyus, I suppose that there are no scripts available for IE8, either on IE7Pro or otherwise? –  ThomasMcLeod Jan 31 '11 at 17:03
    
@Thomas You can install userscripts with IE7Pro. –  nyuszika7h Jan 31 '11 at 17:04
    
@Nyus, can I use them as is, or are mods required? –  ThomasMcLeod Jan 31 '11 at 17:05
    
@Thomas Just install it, reload SO and it works. –  nyuszika7h Jan 31 '11 at 17:06

The order you listed should work find, as long as you have the code selected for ctrl-k or the {} button.

share|improve this answer
    
Only is doesn't. The line enddings and indentation disappear. –  ThomasMcLeod Jan 31 '11 at 3:14
    
@Thomas, so it does copy the text, just not the indentations? Might want to mention that in your question because it just sounds like you can't copy and paste. Regardless, I don't loose indentation when copying from a question or answer, not sure if it makes a difference but I am using Chrome instead of IE8. –  jzd Jan 31 '11 at 12:10
1  
I just tried Chrom and it works as expected. I like IE, but maybe Chrome is a better platform for SO. –  ThomasMcLeod Jan 31 '11 at 14:55
    
BTW, my question refers to pasting "formatted code" –  ThomasMcLeod Jan 31 '11 at 14:57
    
@Thomas, Just checked and it works fine in Firefox, so that is another option. I never use IE so I haven't run into the issue you were facing. –  jzd Jan 31 '11 at 15:04

Just as you need to format code in a question using the curly-brace icon, you need to do the same thing in an answer.

You can preface a line of code with 4 spaces or surround a short segment with ` characters (the apostrophe-like character to the left of the 1 key).

Select a block of code and hit the curly-brace key to format the whole block.

share|improve this answer

You must log in to answer this question.

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