|
I pressed the "101 010" button and its says place code here. I cut and paste right where it says "enter code here", but my code is never formatted correctly. Would someone please explain how to format my code in a little more detail? Thanx
(comments are locked)
|
|
I usually just paste some code, select it all, and press the 101 010 button. So, make sure you have selected your code before pressing 101 010 button. Actually, I just format it in my editor before sending it out, it's easier imo. Just make sure you got 4 spaces before each line of code. I select all text, press tab to indent them with 4 spaces, then I copy & paste it here. (Upvoted and selected this as the right answer)
Jul 29 '11 at 11:19 AM
CHPedersen
(comments are locked)
|
|
As an addition to the other answers here, all the formatting rules apply in the comments space as well as in the Q&A forms, there's just no handy formatting feature for it. In the case I want to put code into a comment, I either add 4 spaces (if it's a short snippet) or compose the comment in the answer box first, ensure it's formatted correctly, then cut/paste it into the comment field. The formatting is based on Markdown Syntax and you can use many of the features listed in the syntax reference here.
(comments are locked)
|
|
if you format your code with the 101010-button and work on it afterwards, sometimes that breaks the formating again. so personally I prefer formating-tags: < /code> < /pre> (you have to remove the space after the ' < ' for them to work) also note: all other html-tags for formatting (order and unorderd lists, bold, links etc work just as fine) EDIT: Warning: apparently some browsers display the tags instead of formatting the code :(( booh! Greetz, Ky.
(comments are locked)
|
|
All I do is press that button, copy my code, highlight where is says "enter code here" and then just paste. And I have also noticed that if you don't indent between curly braces it tends to not format correctly. Actually, that's the wrong way (at least in Chrome). It'll only indent the first line of code. Paste the code, select the code, then press the 101 010 button.
Jul 28 '11 at 12:40 PM
Statement ♦♦
Good thing I don't use Chrome then. Works every time in Firefox.
Jul 28 '11 at 12:49 PM
dibonaj
I should also note that I am insanely picky when it comes to formatting my code inside of MonoDevelop (or anything I may be using to do my coding in). So I don't know if you have "poor" formatting techniques if that'll translate over to how it gets pasted here.
Jul 28 '11 at 12:57 PM
dibonaj
Thanx Guys. Well my code is nice and then ends up scrambled. Thanx again guys.
Jul 28 '11 at 04:49 PM
DFiable
dibonaj, are you sure about that? I don't mean to go into a crusade or anything but I picked the first answer from you that I could find some code in, and it's wrong. http://answers.unity3d.com/questions/147225/infinitely-repeating-sound-when-minimizing-web-pla.html The first line is indented, the second line is not. It's a flurry of indented and non-indented.
Jul 28 '11 at 05:14 PM
Statement ♦♦
(comments are locked)
|

I'm wondering, are you guys also experiencing problems with line spacing when copy-pasting from MonoDevelop? For me, and some others, between each line a blank line gets inserted.
Any way to prevent this?
@Joshua I see random empty lines inserted when pasting from Visual Studio as well...
That sounds like newline format mismatch to me. What browser are you guys using? http://en.wikipedia.org/wiki/Newline
+1 for asking a question all posters can benefit from. :) (Correctly formatted code == getting yelled at less && receive more help) = true
@Christian H Pedersen :
Unknown identifier :P