It seems, from the reference linked to my right as I type, that to put in code snippets I need to indent everything at least four spaces. Is there some easy way to do this automatically for a large block? I imagine that SO would have solved this since that's a site about coding, but I can't see how it's done.

(MarkdownExtra solves this by allowing "fenced" code blocks: pre- and append the block with a line consisting of three (or more) tildes.)

3 Answers 3


You can select the text you want to convert to a code snippet and press the Code Sample button in the bar above the text area (or, alternatively, Ctrl+K). Is that what you want or am I missing something?

  • Perhaps it's a mark of how much of a commandline junkie I am that I automatically blank that out from my field of vision! That's exactly what I want. Thanks. Jul 27, 2010 at 10:31
  • 1
    Just for others: On Mac OSX it’s cmd+K
    – Tobi
    Jul 9, 2011 at 18:40

For TeX code please use the code sample button (now looks like {}; shortcut CTRL+K). For non-TeX we previously suggested to use manual <pre> .. </pre> HTML tags. However a better solution is to use the code sample button as well but add a HTML comment before it to specify the language for the syntax highlighting.

<!-- language: lang-none -->

    some code without syntax highlighting
    note the HTML comment and the single separation line beforehand

Relevant languages for TeX.SX are lang-tex (default), lang-none (disable syntax highlighting), lang-sh (shell code/scripts) and lang-perl (Perl code/scripts). For a list of all languages see: Manually specify language for syntax highlighting


Besides using that 101010 button on the toolbar, you could just use <pre>.


But using <pre> there will be no code highlighting.

  • 1
    and in <pre> you have to manually escape &gt; and &lt; too Jul 28, 2010 at 7:33
  • and the "101010" button now is a "{ }" button. (As of right now, only on the main site, not on meta yet.)
    – doncherry
    Jun 3, 2011 at 19:54

You must log in to answer this question.

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