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



  • 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)!



  • 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.



  • 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?



  • 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
    }
    @



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

    Thanks.



  • 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!



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

    Should I blow away my prefs file and start over?



  • 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 :-)



  • OK...I can wait.


  • Moderators

    "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.



  • 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.



  • 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.



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



  • 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.


  • Moderators

    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...



  • 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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.