Qt Creator turns some of my spaces into tabs without any questions/setting breaking indentation. [SOLVED]



  • In my program I have something like this:
    @ui->plainTextEdit->textCursor().insertText(QString("blabla blablabla very long string");@
    I wanted to fit it in one screen so I made it look like this:
    @ui->plainTextEdit->textCursor().insertText(QString("blabla blablabla"
    . "very long string");@

    But no matter what setting I choose/disable (i want to keep tabulation with tabs though)
    even if I make it all spaces by hand it makes everything but the last few space - tabs.
    And it looks bad on github. I mean even if I make it all spaces, check that it all spaces - as soon as I save file it changes them back to tabs.


  • Moderators

    Hi,

    What version of Qt Creator are you using?

    I believe the relevant setting for your use-case is

    • Tools -> Options -> C++ -> Code Style -> Edit... -> General -> Align continuation lines -> With Spaces

    (Note: If you don't want to Edit a built-in style, click "Copy..." first to create a new style)



  • [quote author="JKSH" date="1411472092"]Hi,

    What version of Qt Creator are you using?

    I believe the relevant setting for your use-case is

    • Tools -> Options -> C++ -> Code Style -> Edit... -> General -> Align continuation lines -> With Spaces

    (Note: If you don't want to Edit a built-in style, click "Copy..." first to create a new style)[/quote]
    Qt Creator 3.2.1

    This setting changes only if the few latest chars will be spaces or tabs. I mean it still would do everything in tabs and if it's not enough - use spaces (like 5 five spaces tabs and then 3 spaces after that).


  • Moderators

    So if I understood correctly, you want all spaces, and no tabs?

    Set:

    • Tools -> Options -> C++ -> Code Style -> Edit… -> General -> Tab policy -> Spaces Only
    • Tools -> Options -> C++ -> Code Style -> Edit… -> General -> Align continuation lines -> With Spaces

    Also set:

    • Tools -> Options -> Text Editor -> Behavior -> Tab Policy -> Spaces Only
    • Tools -> Options -> Text Editor -> Behavior -> Align continuation lines -> With Spaces


  • [quote author="JKSH" date="1411481739"]So if I understood correctly, you want all spaces, and no tabs?

    Set:

    • Tools -> Options -> C++ -> Code Style -> Edit… -> General -> Tab policy -> Spaces Only
      *Tools -> Options -> C++ -> Code Style -> Edit… -> General -> Align continuation lines -> With Spaces

    Also set:

    • Tools -> Options -> Text Editor -> Behavior -> Tab Policy -> Spaces Only
    • Tools -> Options -> Text Editor -> Behavior -> Align continuation lines -> With Spaces[/quote]

    No. I want to keep tabs for code tabulation. I want to anything besides that (especially if it's needed for good looking code align) to use spaces (so that would be same with different tab settings).

    Here, I copied before and after to pastebin (check raw):
    http://pastebin.com/HbYVigSq

    I want to add that using auto-indentation (ctrl+i) and overall - it makes it as i want BUT for some reason after save it becomes wrong!



  • Have you tried to disable ?

    • Tools -> Options -> Text Editor -> Behavior -> Cleanups Upon Saving


  • [quote author="andreyc" date="1411484744"]Have you tried to disable ?

    • Tools -> Options -> Text Editor -> Behavior -> Cleanups Upon Saving[/quote]

    Thanks! That helped! Hope it doesn't disable/break some of other features I used too without me knowing.


Log in to reply
 

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