3
$\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$
3
  • $\begingroup$ Use a proper IDE and go ctrl-A tab and you're done. :-) $\endgroup$
    – Peter K. Mod
    Jan 6, 2017 at 23:10
  • $\begingroup$ used to be ctrl-]. $\endgroup$ Jan 7, 2017 at 1:09
  • $\begingroup$ you mean command-mode >. $\endgroup$ Jan 8, 2017 at 12:36

2 Answers 2

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$
5
  • $\begingroup$ i'll give it a try. $\endgroup$ Jan 8, 2017 at 19:26
  • $\begingroup$ the <pre> tag is the way to go $\endgroup$
    – Matt L.
    Jan 8, 2017 at 20:44
  • $\begingroup$ The triple-backtick works in desktop, but mis-renders without line breaks on mobile $\endgroup$ Jan 10, 2017 at 1:03
  • $\begingroup$ please tell me you don't have a class pre; std::vector<pre> prepositions_vector; in your C++... $\endgroup$ Jan 12, 2017 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$ Jan 12, 2017 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$
3
  • $\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$ Jan 7, 2017 at 1:08
  • 2
    $\begingroup$ @robertbristow-johnson: The curly braces button does do that for you, is there something I'm missing? $\endgroup$ Jan 11, 2017 at 21:16
  • $\begingroup$ maybe it's something i am missing. i'll fiddle with it again. $\endgroup$ Jan 11, 2017 at 21:53

You must log in to answer this question.

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