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. [SOLVED] editor seems to be ignoring my preference settings for tabs instead of spaces
QtWS25 Last Chance

[SOLVED] editor seems to be ignoring my preference settings for tabs instead of spaces

Scheduled Pinned Locked Moved Qt Creator and other tools
18 Posts 7 Posters 23.7k 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.
  • M Offline
    M Offline
    mzimmers
    wrote on 21 Sept 2011, 17:23 last edited by
    #1

    Sorry to bother the forum with such a little issue, but this is driving my crazy. I cannot for the life of me get the editor to insert tabs instead of spaces. Here's a tiff of my settings; can anyone tell me what I might be doing wrong? Thanks.

    !http://www.scopedin.com/images/prefs.jpg(prefs)!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 21 Sept 2011, 19:37 last edited by
      #2

      Is it for new tabs or existing formatting? As far as I know, the latter is not touched. You might want to force a reformatting by using Cmd-A and then Cmd-I.

      Also, be aware that your indent size is 4, so the first indent will be with 4 spaces, the second indent (which is at col 8) uses a tab, the next one a tab and 4 spaces, then 2 tabs, and so on. You should sync the tab width and indent size to the same value in order to always use tabs.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mzimmers
        wrote on 21 Sept 2011, 19:42 last edited by
        #3

        Hi, Volker –

        It's for new tabs: when I put one in, and then hit delete, it erases one character at a time.

        Not sure what you mean by syncing the tab width and indent size. If I reset my indent to 8, will that address your point?

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 21 Sept 2011, 20:44 last edited by
          #4

          Yep.

          Some ASCII art:

          @
          // for tab width = 8, indent = 4:
          void foo_8_4(int x)
          {
          int y = x * 2; // 4 spaces
          if(y == x) { // 4 spaces
          qDebug() << "hooray"; // 1 tab
          if(x % 2) // 1 tab
          qDebug() << "yay"; // 1 tab + 4 spaces
          } // 4 spaces
          }

          // for tab width = 4, indent = 4:
          void foo_4_4(int x)
          {
          int y = x * 2; // 1 tab
          if(y == x) { // 1 tab
          qDebug() << "hooray"; // 2 tabs
          if(x % 2) // 2 tabs
          qDebug() << "yay"; // 3 tabs
          } // 1 tab
          }
          @

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mzimmers
            wrote on 21 Sept 2011, 20:53 last edited by
            #5

            OK...but I'm still getting spaces and odd behavior. Would you mind sharing a screen shot of your editor->behavior settings?

            Thanks.

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on 21 Sept 2011, 21:08 last edited by
              #6

              These are the settings. I think you'll have to match by position, as I do have a German localization :-)

              So this are the settings:

              !http://qdn.berlinbikerx.de/QtCreator-Settings-Editor.png!

              And this is the result with the sample function from above with spaces/tabs displayed:

              !http://qdn.berlinbikerx.de/Editor-with-tabs-4-4.png!

              This is the result with tabwidth = 8 and indent = 4:

              !http://qdn.berlinbikerx.de/Editor-with-tabs-8-4.png!

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mzimmers
                wrote on 21 Sept 2011, 21:32 last edited by
                #7

                Damn...it's STILL inserting spaces instead of tabs.

                Should I blow away my prefs file and start over?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on 21 Sept 2011, 21:35 last edited by
                  #8

                  Hm, I don't believe that helps. Maybe waiting a day or two and having one of the Creator Trolls jump in could bring that forward :-)

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mzimmers
                    wrote on 21 Sept 2011, 21:37 last edited by
                    #9

                    OK...I can wait.

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      tobias.hunger
                      wrote on 22 Sept 2011, 06:45 last edited by
                      #10

                      "File a bug report":http://bugreports.qt.nokia.com/ if you want to see a troll at the issue:-) Seriously: Most trolls do not read all the messages posted and will miss topics brought up here.

                      Qt Creator now does define the indention settings at the global level as well as on the project level. Is your project maybe overriding your global settings? Check Projects->Somewhere there, don't have creator around right now.

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        mzimmers
                        wrote on 23 Sept 2011, 23:14 last edited by
                        #11

                        Hi, Tobias –

                        You're referring to Projects->Editor Settiings. I had that overriding my default preferences, but it's since been returned to use "globals."

                        I think that may have been part of the solution, because I can no longer replicate the problem. As such, a bug report wouldn't be appropriate. Thanks for the suggestion.

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          trallallero
                          wrote on 7 Feb 2013, 11:46 last edited by
                          #12

                          I had the same problem and I've found out that for the C/C++ files qt creator uses the Code Style settings (Projects->Code Style->Current Settings) overriding all other setting defined in other places. So it's not a bug.

                          1 Reply Last reply
                          2
                          • M Offline
                            M Offline
                            mzimmers
                            wrote on 7 Feb 2013, 13:48 last edited by
                            #13

                            Oh, that's good information. Thanks, trallallero.

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              AnatolyK
                              wrote on 11 Aug 2013, 12:09 last edited by
                              #14

                              As to tabs in Qt Creator... I don't understand the version of your Qt Creator Mr Volker. I have 2.6.2. So available 2.8. But not integrated with my OS. I don't like all environments and update repositories tune manually. There are some versions difference. After some study tab aspects for Qt Creator of my version I get to know that impossible to insert ant tab symbol throw keyboard. But you may insert at least 1 tab using copy paste. And you need keep all you tabs untouched and continue with tabs all next code/ Indentation, formatting and so on... But if previous cod there are no space/tab indentation all try to insert tab indent always insert spaces instead of tabs. Unfortunately Qt Creator can't do any more in this aspect. I don't think anything changed in next versions of Qt Creator. I see 2.8 There is the same tab functional... So if you love tab indentation(I am) it's take some efforts to do so.

                              1 Reply Last reply
                              0
                              • T Offline
                                T Offline
                                tobias.hunger
                                wrote on 12 Aug 2013, 08:30 last edited by
                                #15

                                Unfortunately there is little we can do from our side to make sure all Linux distributions include the most current version of Qt Creator.

                                It is possible to insert tab characters using the tab key. Set the tab policy to anything but "Spaces only". Note that you can have different settings for "generic editors", C++ editors and QML editors, so make sure you change the right one;-). For C++ code you need to edit in Tools>Options>C++>Coding style and either pick on that matches your preferences or create a new one.

                                Creator will also by default "fix" the indention used on the lines it edits. So that will fix any tabs you manually insert (as long as your tab policy says "no tabs please"). So either choose the preferred tab policy or disable the "Cleanups upon saving" (Tools>Options>Text Editor>Behavior).

                                All these settings should also be in Qt Creator 2.6.x, but the UIs might have moved around a bit...

                                1 Reply Last reply
                                0
                                • T Offline
                                  T Offline
                                  tseiff
                                  wrote on 12 Jan 2015, 23:56 last edited by
                                  #16

                                  If you are still banging your head like I was, and you are using FakeVim, check those settings. They seem to be yet another layer of override and you have to manually check "Expand Tabulators", even if you already specified this TWICE via global and project settings.

                                  Then go ice your head.

                                  Qt Creator 3.3.0

                                  1 Reply Last reply
                                  2
                                  • T Offline
                                    T Offline
                                    tseiff
                                    wrote on 12 Jan 2015, 23:56 last edited by
                                    #17

                                    If you are still banging your head like I was, and you are using FakeVim, check those settings. They seem to be yet another layer of override and you have to manually check "Expand Tabulators", even if you already specified this TWICE via global and project settings.

                                    Then go ice your head.

                                    Qt Creator 3.3.0

                                    M 1 Reply Last reply 14 Dec 2020, 18:27
                                    3
                                    • T tseiff
                                      12 Jan 2015, 23:56

                                      If you are still banging your head like I was, and you are using FakeVim, check those settings. They seem to be yet another layer of override and you have to manually check "Expand Tabulators", even if you already specified this TWICE via global and project settings.

                                      Then go ice your head.

                                      Qt Creator 3.3.0

                                      M Offline
                                      M Offline
                                      MKerr
                                      wrote on 14 Dec 2020, 18:27 last edited by
                                      #18

                                      @tseiff said in [SOLVED] editor seems to be ignoring my preference settings for tabs instead of spaces:

                                      If you are still banging your head like I was, and you are using FakeVim, check those settings. They seem to be yet another layer of override and you have to manually check "Expand Tabulators", even if you already specified this TWICE via global and project settings.

                                      Then go ice your head.

                                      Qt Creator 3.3.0

                                      This is quite an old post and without it I would have struggled to solve this problem. This functionality is quite silly and should be fixed, or at the very least, documented appropriately.

                                      1 Reply Last reply
                                      1

                                      • Login

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