# Formatting. Comments

**URL:** <https://forums.toadworld.com/t/formatting-comments/54177>\
**Category:** Toad for Oracle - Beta\
**Created:** [November 29, 2021, 11:29am UTC](https://forums.toadworld.com/t/formatting-comments/54177 "2021-11-29T11:29:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ihor\_Taranenko](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/ihor_taranenko/32/13482_2.png) [@Ihor\_Taranenko](https://forums.toadworld.com/u/Ihor_Taranenko)\
**Post date:** [November 29, 2021, 11:29am UTC](https://forums.toadworld.com/t/formatting-comments/54177/1 "2021-11-29T11:29:43Z")

</div>

If comment starts from line beginning, and previous line (contains SQL code) is short, formatter moves comment to the end of previous line.

Example.  
Before formatting:

```auto
select *
  from dual
  where X = X
 -- New Line Comment
 and X = X;

```

After formatting:

```auto
select *
  from dual
 where X = X -- New Line Comment
             and X = X;

```

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [November 30, 2021, 12:56pm UTC](https://forums.toadworld.com/t/formatting-comments/54177/2 "2021-11-30T12:56:06Z")

</div>

Please see [Formatting. Another Comments - #2 by avergison](https://forums.toadworld.com/t/formatting-another-comments/54182/2) . Same case.

Andre

---

<div class="post-metadata">

**Author:** ![michael.r.hinkle](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/michael.r.hinkle/32/283_2.png) [@michael.r.hinkle](https://forums.toadworld.com/u/michael.r.hinkle)\
**Post date:** [November 30, 2021, 1:26pm UTC](https://forums.toadworld.com/t/formatting-comments/54177/3 "2021-11-30T13:26:37Z")

</div>

I am not seeing this behavior. Here is what I get when formatting the SQL you provided:

![image](https://global.discourse-cdn.com/quest/original/2X/0/0572dc5872db4c06ec1393fd7bb89619f6938543.png)

Here are my Formatter settings:  
[FmtPlus - MRH.opt.txt](https://forums.toadworld.com/uploads/short-url/5Gx5BZB3avxlU6wOyMD5gKIFUBr.txt) (974 Bytes)

Once you download the file, just rename the file to remove the .txt from the end and you should be able to import them in Options/Formatter then select the folder icon in the top left for Load Options File. You may want to save your Formatter settings first.

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [November 30, 2021, 1:42pm UTC](https://forums.toadworld.com/t/formatting-comments/54177/4 "2021-11-30T13:42:10Z")

</div>

(edited)  
I'm getting Michael's output as well.

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [November 30, 2021, 1:48pm UTC](https://forums.toadworld.com/t/formatting-comments/54177/5 "2021-11-30T13:48:35Z")

</div>

> [@michael.r.hinkle](#):
>
> Once you download the file, just rename the file to remove the .txt from the end and you should be able to import them in Options/Formatter then select the folder icon in the top left for Load Options File. You may want to save your Formatter settings first.

Another quick way to do this: just copy the bunch of name=value lines and click on the menu top Paste Options from Clipboard. 🙂

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [November 30, 2021, 1:52pm UTC](https://forums.toadworld.com/t/formatting-comments/54177/6 "2021-11-30T13:52:33Z")

</div>

I obtain Ihor's output by using the default options, and THEN my pointer to "Formatting, Another Comments" should apply. In that case the formatter wants:

```auto
SELECT *
  FROM DUAL
 WHERE X = X AND X = X;

```

and again the comment is in the way.

---

<div class="post-metadata">

**Author:** ![dirk.mika1](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/dirk.mika1/32/16503_2.png) [@dirk.mika1](https://forums.toadworld.com/u/dirk.mika1)\
**Post date:** [November 30, 2021, 2:33pm UTC](https://forums.toadworld.com/t/formatting-comments/54177/7 "2021-11-30T14:33:18Z")

</div>

I think it depends on if the formatter tries to avoid stacking. Because of the comments a new line is used, but the list is still not stacked like:

```auto
SELECT *
  FROM DUAL
 WHERE 1 IN (1, --
                2, --
                   3, --
                      4 --
                       );

```

As soon as the stacking limit is reached this becomes:

```auto
SELECT *
  FROM DUAL
 WHERE 1 IN (1, --
             2, --
             3, --
             4, --
             5 --
              );

```

This is because in my settings the limit is 4 items. So depending on your actually settings the result may differ.

I don't know if it makes sense to stack as soon as an (inline) comment forces a new line.

---

<div class="post-metadata">

**Author:** ![avergison](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/avergison/32/66_2.png) [@avergison](https://forums.toadworld.com/u/avergison)\
**Post date:** [November 30, 2021, 4:04pm UTC](https://forums.toadworld.com/t/formatting-comments/54177/8 "2021-11-30T16:04:21Z")

</div>

Hi Dirk, in your example formatter wants everything on a same line but the comments - which require a terminating newline each - force the code to continue on the next line. Formatter preserves the horizontal offsets (columns). Whenever items are added then modes changes to stacking and then the comments don't disturb anymore. Unless you'd change comma style to "leading" ...

```auto
SELECT *
  FROM DUAL
 WHERE 1 IN (1
            , --
             2
            , --
             3
            , --
             4 --
              );

```

---

<div class="post-metadata">

**Author:** ![dirk.mika1](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/dirk.mika1/32/16503_2.png) [@dirk.mika1](https://forums.toadworld.com/u/dirk.mika1)\
**Post date:** [December 1, 2021, 6:31am UTC](https://forums.toadworld.com/t/formatting-comments/54177/9 "2021-12-01T06:31:08Z")

</div>

Thanks for the explanation. But don't you agree that something like

```auto
SELECT *
  FROM DUAL
 WHERE 1 IN (1, --
                2, --
                   3, --
                      4 --
                       );

```

doesn't makes sense. 😉  
Hence my suggestion that if a comment forces a line feed, the formatter stacks the elements regardless of the setting?
