2

How can I make it so this,

The primary network interface

auto eth1 iface eth1 inet dhcp

looks the same as it appears on the monitor, like this:

# The primary network interface
auto eth1
iface eth1 inet dhcp
1
  • I'm not sure how it magically edited itself but on ask-ubuntu it does not appear like that without some extra work.
    – Cam Jones
    Commented Mar 14, 2014 at 21:27

2 Answers 2

8

Code formatting is done in several ways:

If it's inline code you add backticks (`) around it. This is some inline formatting.

For code on it's own line you indent it by four spaces:

This is code on it's own line.

Or you can use the code button on the toolbar:

enter image description here

Which can also be activated with Ctrl+K.

For more information see formatting help.

1
  • 2
    Make sure that you've got a blank line before the code block if you're doing it manually. The code button does this for you.
    – kiri
    Commented Mar 15, 2014 at 10:30
0

One incredibly annoying behaviour of the editor shortcut is that it doesn't account for levels. If you try to embed code within a list, you'll need to add the indentation once more (and more times per level). So:

 - some text

    code

Shows up as:

  • some text

    code

You can add it manually, but one trick is to indent the code, then in the first line of the block, add a character at the start of the line, and then indent it again:

- some text
code

Becomes:

- some text

    code

Then:

- some text

a    code

Then:

- some text

    a    code

And finally delete that extra character.

Backticks work in lists, but backtick-quoted code blocks aren't as nicely formatted as the indented version.

You must log in to answer this question.

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