# How to post code with more than 1 line?

**URL:** <https://techcommunity.softwareag.com/t/how-to-post-code-with-more-than-1-line/228879>\
**Category:** Feedback & ideas\
**Created:** [July 20, 2020, 7:45am UTC](https://techcommunity.softwareag.com/t/how-to-post-code-with-more-than-1-line/228879 "2020-07-20T07:45:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [July 20, 2020, 7:45am UTC](https://techcommunity.softwareag.com/t/how-to-post-code-with-more-than-1-line/228879/1 "2020-07-20T07:45:43Z")

</div>

Hi,

my question is: How can I post a code snippet with more than 1 line. I’m using the code-Tags.

sample:

`write "line1"
write "line2"
end`

Believe me: There is a newline between the two write-statements.

Regards

Matthias

---

<div class="post-metadata">

**Author:** ![toni.petrov](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/toni.petrov/32/23700_2.png) [@toni.petrov](https://techcommunity.softwareag.com/u/toni.petrov)\
**Post date:** [July 20, 2020, 8:03am UTC](https://techcommunity.softwareag.com/t/how-to-post-code-with-more-than-1-line/228879/2 "2020-07-20T08:03:09Z")

</div>

Hi Matthias,

To me the easiest is to:

1. On a new line click the code button ![image](https://global.discourse-cdn.com/techcommunity/original/2X/3/3c3a39240ece588c4552ac17a64545cd2f368b73.png)
2. Paste the code in the place of `type or paste code here` i.e.

```auto
write "line1" 
write "line2" end

```

---

<div class="post-metadata">

**Author:** ![toni.petrov](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/toni.petrov/32/23700_2.png) [@toni.petrov](https://techcommunity.softwareag.com/u/toni.petrov)\
**Post date:** [July 20, 2020, 8:32am UTC](https://techcommunity.softwareag.com/t/how-to-post-code-with-more-than-1-line/228879/3 "2020-07-20T08:32:48Z")

</div>

If you don’t want to use the button you can also Instead, use 3 backticks (```) on their own line above and below your code. Be sure there are no spaces on the lines with the backticks, or this will not work.

### Example:

**Typing:**

````auto
```
public class CodeFormatting {
    public static void main(String[] args) {
        System.out.println("I can format code now!");
    }
}
```
````

**Produces:**

```auto
public class CodeFormatting {
    public static void main(String[] args) {
        System.out.println("I can format code now!");
    }
}

```

## Automatic code styling

The forums will _try_ to automatically detect what language you are typing and style your code accordingly. This might be nice for sharing code, but tends to produce strange results when sharing other preformatted text. To avoid the automatic styling, declare your code to be “raw text” by typing `text` after the first 3 back ticks.

### Example:

**Typing:**

````auto
```text
public class CodeFormatting {
    public static void main(String[] args) {
        System.out.println("I can format code now!");
    }
}
```
````

**Produces:**

```plaintext
public class CodeFormatting {
    public static void main(String[] args) {
        System.out.println("I can format code now!");
    }
}

```

In addition to `text` , you can manually choose the formatting of a code block with the following selectors: `apache` , `bash` , `coffeescript` , `cpp` , `cs` , `css` , `diff` , `handlebars` , `http` , `ini` , `java` , `javascript` , `json` , `makefile` , `markdown` , `nginx` , `objectivec` , `perl` , `php` , `python` , `ruby` , `sql` , `xml` .

---

<div class="post-metadata">

**Author:** ![toni.petrov](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/toni.petrov/32/23700_2.png) [@toni.petrov](https://techcommunity.softwareag.com/u/toni.petrov)\
**Post date:** [July 20, 2020, 8:34am UTC](https://techcommunity.softwareag.com/t/how-to-post-code-with-more-than-1-line/228879/4 "2020-07-20T08:34:38Z")

</div>

Finally you can use `[code][/code]` i.e.

```auto
[code]
public class CodeFormatting {
    public static void main(String[] args) {
        System.out.println("I can format code now!");
    }
}
[/code]

```

will produce:

```auto
public class CodeFormatting {
    public static void main(String[] args) {
        System.out.println("I can format code now!");
    }
}
```

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [July 20, 2020, 1:41pm UTC](https://techcommunity.softwareag.com/t/how-to-post-code-with-more-than-1-line/228879/5 "2020-07-20T13:41:13Z")

</div>

this [code]-thing didn’t work.  
But now I know, why.

```auto
[code]line 1
line 2[/code]
```

results in

`line 1
line 2`

while

```auto
[code]
line 1
line 2
[/code]
```

results in

```auto
line 1
line 2
```

… strange.
