Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 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

Possible Duplicate:
How do I format my code blocks?

Is there a dirt-simple way to post code snippets in a StackOverflow answer?

I've been putzing around the with either the 'inline' code curly braces, or this 'indent 4 spaces' concept. Still losing whitespace and/or wordwrapping where it shouldnt be.

share|improve this question

migrated from Jun 8 '12 at 20:54

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

marked as duplicate by Shadow Wizard, slhck, kiamlaluno, random Jun 9 '12 at 13:47

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.

Copy code, select it, Ctrl+K? Or I'm missing something? – om-nom-nom Jun 8 '12 at 20:55
Well while the selected answere worked on some limited testing. On this question,…, still unable to get the code to format properly if copy-pasted then using the curly braces. You will see that instead, I linked to a posting on Microsoft Script Center. – Real World IS Jun 10 '12 at 4:43
Brand spanking new :… – CodyBugstein Sep 17 '14 at 14:44
up vote 4 down vote accepted

Hold down Shift while you select the code block with either the mouse or arrow keys, this should highlight the block.

Now hit the {} button above the entry box, this should indent all the selected code by the necessary 4 spaces and also put blank lines before and after if necessary. You can see the effect immediately in the preview below the entry box.

share|improve this answer

In your favorite code editor, ensure that the farthest left indent of the code that you are about to copy is four characters from the left margin of the editor. Once you've done this, select and copy. Then, when you paste in the editor, you're already done.

For example, in my case, I'll select my code (visual studio), hit shift-tab (decrease indent) until at least one line of code has touched the left margin of the code editor, then I'll hit tab once. That adds four spaces of indent to the code. I then copy and paste it into the question editor.

share|improve this answer

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