Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Can I completely disable line wrapping in QtCreator C++ editor?
QtWS25 Last Chance

Can I completely disable line wrapping in QtCreator C++ editor?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
10 Posts 3 Posters 770 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fafnir
    wrote on last edited by fafnir
    #1

    I would like to configure the QtCreator C++ editor in such a way that all those indentation rules work (for example, if I set the "public:" inside a class to be indented, I want it to work) when I press Ctrl+;
    but at the same time I want to lines to stay exactly the way I wrote them, plus any indentation fixes if I configured those fixes.

    I have a line which looks like this (should be a single long line):

    Screenshot_20240723_115656.png

    When I press Ctrl+; to format the selected text (including that line above), I get this:

    Screenshot_20240723_115607.png

    Is there a way to make sure that a line - however long it is - will NOT be broken into multiple lines?

    Please advise.
    I am kinda desperate already.
    For the past several months, I have been paying for CLion simply because its formatting makes (or rather, keeps) my code readable. But CLion suddenly started doing pretty much the same nonsense, even though I did not even touch the settings or do any kind of resets. So, I don't even want it anymore. QtCreator has a far more superior debugger, AND it consumes far less memory and CPU. It's just this auto-wrapping problem is driving me nuts. Please help.

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #8

      It's not Qt Creator that wraps your line. When CTRL+; is pressed, the Clang formatter is invoked (in my case ClangFormat version 17.0.1.). That's an external formatter, which acts according to its specification. If you don't like it, don't use it. You can't bake an omelet without breaking eggs.

      Software Engineer
      The Qt Company, Oslo

      F 1 Reply Last reply
      2
      • Axel SpoerlA Offline
        Axel SpoerlA Offline
        Axel Spoerl
        Moderators
        wrote on last edited by
        #2

        image.png

        Software Engineer
        The Qt Company, Oslo

        F 1 Reply Last reply
        0
        • Axel SpoerlA Axel Spoerl

          image.png

          F Offline
          F Offline
          fafnir
          wrote on last edited by
          #3

          @Axel-Spoerl
          I am sorry, I do not understand what your screenshot means.
          I checked, and my settings are precisely the same.
          The only one which sounds like it could help, which is "Align continuation lines" --> "Not at all", did not change the wrapping.
          No other settings seem to be related to the line-wrapping issue.

          My settings:

          Screenshot_20240723_124805.png

          1 Reply Last reply
          0
          • Axel SpoerlA Offline
            Axel SpoerlA Offline
            Axel Spoerl
            Moderators
            wrote on last edited by
            #4

            Maybe I misunderstood wrapping with indentation. Sorry about that.
            Move to the "Display" tab, and disable line wrapping there.

            Software Engineer
            The Qt Company, Oslo

            F 1 Reply Last reply
            0
            • Axel SpoerlA Axel Spoerl

              Maybe I misunderstood wrapping with indentation. Sorry about that.
              Move to the "Display" tab, and disable line wrapping there.

              F Offline
              F Offline
              fafnir
              wrote on last edited by
              #5

              @Axel-Spoerl
              The one setting I see there, "Enable text wrapping", was already unchecked.
              Just in case, I checked it, tested, unchecked again and re-tested.
              I did not affect the line wrapping. It's still the same.

              Screenshot_20240723_140749.png

              1 Reply Last reply
              0
              • Axel SpoerlA Offline
                Axel SpoerlA Offline
                Axel Spoerl
                Moderators
                wrote on last edited by
                #6

                I think we are talking about different things.
                The line wrapping forces a wrap, when you type over the maximum length of a line.
                If I toggle it, it works as expected.

                It looks to me, that it does that also for you. It would be a serious bug, if it wouldn’t.

                After re-reading your post, it is not about line wrapping as the title suggests. It’s about what the code formatter does with a long, unwrapped line.

                Am I right?
                So which code formatting settings do you use?

                Software Engineer
                The Qt Company, Oslo

                F 1 Reply Last reply
                0
                • Axel SpoerlA Axel Spoerl

                  I think we are talking about different things.
                  The line wrapping forces a wrap, when you type over the maximum length of a line.
                  If I toggle it, it works as expected.

                  It looks to me, that it does that also for you. It would be a serious bug, if it wouldn’t.

                  After re-reading your post, it is not about line wrapping as the title suggests. It’s about what the code formatter does with a long, unwrapped line.

                  Am I right?
                  So which code formatting settings do you use?

                  F Offline
                  F Offline
                  fafnir
                  wrote on last edited by
                  #7

                  @Axel-Spoerl
                  On the "C++" -> "Code Style" -> "Clang Format Settings" -> "Formatting mode" dropdown, I tried all 3 settings, and I also tried changing a lot of settings when using "Use custom settings" and playing with lots of various options in the long list of "Clang format", based on either GNU (built-in) or Qt (built-in) standard settings.
                  Nothing that I tried seemed to keep my long lines unbreakable.

                  JonBJ 1 Reply Last reply
                  0
                  • Axel SpoerlA Offline
                    Axel SpoerlA Offline
                    Axel Spoerl
                    Moderators
                    wrote on last edited by
                    #8

                    It's not Qt Creator that wraps your line. When CTRL+; is pressed, the Clang formatter is invoked (in my case ClangFormat version 17.0.1.). That's an external formatter, which acts according to its specification. If you don't like it, don't use it. You can't bake an omelet without breaking eggs.

                    Software Engineer
                    The Qt Company, Oslo

                    F 1 Reply Last reply
                    2
                    • F fafnir

                      @Axel-Spoerl
                      On the "C++" -> "Code Style" -> "Clang Format Settings" -> "Formatting mode" dropdown, I tried all 3 settings, and I also tried changing a lot of settings when using "Use custom settings" and playing with lots of various options in the long list of "Clang format", based on either GNU (built-in) or Qt (built-in) standard settings.
                      Nothing that I tried seemed to keep my long lines unbreakable.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by JonB
                      #9

                      @fafnir
                      I don't use or know about this, but does one of the suggestions in, say, Can you set clang-format's line length? (from a few years ago) work for you to stop where it is line breaking?

                      Reference material at https://clang.llvm.org/docs/ClangFormatStyleOptions.html. [Oh, Axel already referenced same.]

                      1 Reply Last reply
                      2
                      • Axel SpoerlA Axel Spoerl

                        It's not Qt Creator that wraps your line. When CTRL+; is pressed, the Clang formatter is invoked (in my case ClangFormat version 17.0.1.). That's an external formatter, which acts according to its specification. If you don't like it, don't use it. You can't bake an omelet without breaking eggs.

                        F Offline
                        F Offline
                        fafnir
                        wrote on last edited by
                        #10

                        @Axel-Spoerl @JonB
                        Thank you very much for your help!

                        I had ColumnLimit set to a very generous number, well above the lines' lengths that started wrapping all of a sudden a couple of days ago, but after I set it to an even greater number (300, to be exact), the line wrapping is working again as expected.

                        Thank you!

                        1 Reply Last reply
                        0
                        • F fafnir has marked this topic as solved on
                        • F fafnir has marked this topic as solved on

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved