5
$\begingroup$

Is it possible to use tabs in posts?
When I paste a tab (the browser catches the input of pressing Tab and changes the selected field, so I have to paste it in) into a post, it works in the editing box, but does not appear in the rendered markdown version.

Is this possible? If not, is there some way to get equivalent functionality?

$\endgroup$
3
$\begingroup$

You can't use an actual tab for the same reason you said above. StackExchange sites function like most other sites as opposed to a code editor so Tab behaves like it should. You have to use spaces but not the normal ones as SE will ignore whitespace for the most part and 4+ spaces triggers a block of code in markdown.

I actually have two spaces here. (click edit on this answer to check)

# and the four spaces before this have made it into code..

So, one way you can achieve this is by using html, as obviously, SE supports a subset.

Use   to get a space. Join more together for more space(s).

  is the entity used to represent a non-breaking space. It is essentially a standard space, the primary difference being that a browser should not break (or wrap) a line of text at the point that this occupies. (src)

Eg.

  Two space indentation
    Four space indentation
        Eight space indentation

Also, there is a user script on stackapps that might be of some interest if you really need this to work.

This user script changes the behavior of a few keys (most notably the Tab key) within the post editor to behave more like it does in IDEs or text editors:

$\endgroup$
4
  • $\begingroup$ What about the way tabs automatically adjust their length to match other tabs above and below? (for an example of this, click edit on this post) $\endgroup$
    – gandalf3 Mod
    Sep 21 '13 at 1:57
  • $\begingroup$ @gandalf3 I'm not sure what I'm supposed to be seeing here. Those aren't tabs, those are 4 spaces and as I said, SE strips or doesn't render whitespace for more than one space in a line. $\endgroup$
    – iKlsR
    Sep 21 '13 at 2:00
  • $\begingroup$ Did you look between the tags and the arrows when editing? (not in the rendered version, but the versions in the edit box) $\endgroup$
    – gandalf3 Mod
    Sep 21 '13 at 2:10
  • $\begingroup$ @gandalf3 SE will preserve the spaces while editing but it won't render them. It's a good way to organize long posts and space content but it won't be rendered when saved. $\endgroup$
    – iKlsR
    Sep 21 '13 at 2:11

You must log in to answer this question.

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