# What's this stupid thing about having to indent all of your code with 4 spaces for it to be rendered as code?

isn't there some markup hook that i can use to do that?

i'm getting tired of fetching some old C file that i want to simply paste in and having to manually add spaces to many of the lines.

this seems silly.

r b-j

• Use a proper IDE and go ctrl-A tab and you're done. :-) – Peter K. Jan 6 '17 at 23:10
• used to be ctrl-]. – robert bristow-johnson Jan 7 '17 at 1:09
• you mean command-mode >. – Marcus Müller Jan 8 '17 at 12:36

You could do:

<pre>
code
code2
code3
</pre>


which gives you

code
code2
code3


I think triple backticks code should work to:


code
more code
some final code



 code more code some final code 

This should also work:

<code>
code
code2
code3
</code>


which renders as:

 code code2 code3 

The <pre> tag has trouble with HTML special characters < and >:

<pre>
#include <limits.h>
</pre>


gives:

#include

• i'll give it a try. – robert bristow-johnson Jan 8 '17 at 19:26
• the <pre> tag is the way to go – Matt L. Jan 8 '17 at 20:44
• The triple-backtick works in desktop, but mis-renders without line breaks on mobile – Marcus Müller Jan 10 '17 at 1:03
• please tell me you don't have a class pre; std::vector<pre> prepositions_vector; in your C++... – Marcus Müller Jan 12 '17 at 17:38
• @OlliNiemitalo no, seriously, I'll make this answer a community wiki. Please add an example for what doesn't work! – Marcus Müller Jan 12 '17 at 17:39

In fact, just use the curly braces when answering: the SE answer "IDE" has this function automatically. Just hit the curly brace button after selecting the code you want indented.

• Peter, i cut and pasted text from an old C file into the SE window, but i wanted this text to look like code. best that i understand, every line (even the blank lines) has to have a tab or 4 spaces preceding anything else. – robert bristow-johnson Jan 7 '17 at 1:08
• @robertbristow-johnson: The curly braces button does do that for you, is there something I'm missing? – Stefan Monov Jan 11 '17 at 21:16
• maybe it's something i am missing. i'll fiddle with it again. – robert bristow-johnson Jan 11 '17 at 21:53