[Qt-creator] indenting of comments inconsistent?

Nikolai Kosjar nikolai.kosjar at digia.com
Fri Aug 22 13:50:51 CEST 2014

On Thu, 21. Aug 16:37, Cristian Tibirna wrote:
> Commenting a line (or many) with Ctrl+/ puts the // symbol at column 0.
> But hitting Ctrl+I in a commented line indents it with the body of code.
> Yet moving commented lines around with Ctrl+Shift+Arrow* does not obey current 
> block's indentation (like non-commented lines do) and doesn't anchor the 
> commented line at column 0 either.
> Is this intended behavior?

I'm not sure. The original authors are not around anymore.

I suppose that commenting out with Ctrl+/ will insert the "//" at
column 0 in order to make the commented out code striking. Now if you
move such commented lines around, they still should be striking (case
2 below; granted, in that case we probably should indent the code
following the "//"). With that assumption the current behaviour makes
sense. If I write a text comment, I usually insert the "//" by hand -
at that point I'm already in an indented position and the text comment
is not as striking as the comment generated with Ctrl+/. Cool.

But moving an indented comment around should IMHO re-indent to the
block (case 3) as it probably is a text comment. To sum it up:

    void f()
        int n;    // (1) Moving into block below will indent
    //    int n;  // (2) Moving into block below will *not* indent
        // int n; // (3) Moving into block below will *not* indent

For me (1) and (2) are expected, (3) not.


More information about the Qt-creator mailing list