2
$\begingroup$

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

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

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

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.

enter image description here

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – robert bristow-johnson Jan 7 '17 at 1:08
  • 2
    $\begingroup$ @robertbristow-johnson: The curly braces button does do that for you, is there something I'm missing? $\endgroup$ – Stefan Monov Jan 11 '17 at 21:16
  • $\begingroup$ maybe it's something i am missing. i'll fiddle with it again. $\endgroup$ – robert bristow-johnson Jan 11 '17 at 21:53

You must log in to answer this question.

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