- Home /
Best practices for posting code?
I have noticed that posting code and keeping it formatted properly is difficult. The built in formatting is a bit obscure compared to normal forum posts and deals heavily with invisible characters.
I find that sometimes pasting code works and some times it doesn't. The best way seems to be to write it out by hand directly into the site's open window. It seems that the site auto generates some sort of special character or line feed when the user hits return. This seems to break when PASTING code, as the line feeds are included in the paste.
What is the best way to post and PASTE code?
Answer by CHPedersen · Sep 09, 2011 at 12:59 PM
I don't trust the direct auto-formatting of pasted code either; I find it tends to break if I need to add something to it while it's in the textbox, or when I continue the post after the pasted snippet. The best way to get it properly formatted is to just paste it, then highlight the code, and hit the "Code Sample"-button (the one with the "101010" on it).
Also, pay attention to the dynamically updated preview of your post right underneath the textbox - it displays what your post is going to look like. Just play around with the highlighting and the 101010-button until it looks right. It'll increase your chances of getting help for sure. :)
Ah, it's the trick of formatting after! Ah!
I would hit the code (101 010) button first to create the "paste code here" prompt and try to - well - paste code here, and it would usually break.
I'll remember this about PASTING FIRST and FOR$$anonymous$$ATTING AFTER!
I hate trying to tab a line in, only to find it tabs me to the tag section... maybe its just me tho
I'm going to write in a text editor, for tabs, etc., then PASTE here THEN FOR$$anonymous$$AT last... but yes, tabbing in any forum based software sux. Usually I copy and paste a tab character.
Answer by JeevanjotSingh · Nov 04, 2014 at 02:41 PM
it's closed now but guys i just want to inform you that the shortcut for making your text code is ctrl+k after highlighting your code part .
Your answer
![](https://koobas.hobune.stream/wayback/20220612205622im_/https://answers.unity.com/themes/thub/images/avi.jpg)