There is an option to format while typing in the ClangFormat plugin. I was just 
using it 5 minutes ago… 

 

--

Mike Jackson 

 

From: Qt-creator <qt-creator-boun...@qt-project.org> on behalf of Andy 
<asmalo...@gmail.com>
Date: Monday, March 4, 2019 at 8:46 AM
To: Eike Ziller <eike.zil...@qt.io>
Cc: Qt-creator <qt-creator@qt-project.org>
Subject: Re: [Qt-creator] Editor style setting for a submodule (+EditorConfig)

 

Thanks Eike.

 

I have tried all of the code formatting options and could not get the 
formatting I want. uncrustify comes closest, but with the 1,000 options I still 
can't quite get there... Clangformat, for example, couldn't format constructor 
initializers properly unless you add a max line width (if I recall correctly). 
The docs say one thing, but in practice it does something different. I gave up 
trying to fight it. I can adjust my style a bit, but some things... not so much 
:-)

 

"Creating the definition files for these is up to you though."

 

:-)

 

"Also, these are not used for formatting while typing...."

 

That's what I was looking for and why I mentioned EditorConfig since it seems 
to be well supported across editors. Looks like it generally only supports 
whitespace formatting though - but even this would be useful!

 

---
Andy Maloney  //  https://asmaloney.com

twitter ~ @asmaloney

 

 

 

On Mon, Mar 4, 2019 at 3:01 AM Eike Ziller <eike.zil...@qt.io> wrote:



> On 3. Mar 2019, at 19:38, Andy <asmalo...@gmail.com> wrote:
> 
> Is there a way to have two different editor style settings - one for the main 
> project and one for a submodule?
> 
> Use-case: I have my own code in a submodule (lib) within a project that's 
> "not mine". (Using cmake.) When editing in the main project I want to use its 
> style, but when I edit my own code I want it in my style...
> 
> Right now everything uses the main project's style.
> 
> 
> Secondary question: is there a way to persist styles in a repo so everyone 
> uses the same settings? Preferably using a "standard" like EditorConfig so 
> that non QtC-users can participate as well?

I’d try enabling the Beautifier plugin and using one of the code styling tools 
that it supports (clang-format, astyle, uncrustify). You can check the format 
definitions for these into the repo, and Qt Creator should take the first 
definition it finds in the parent folder hierarchy (or at least can be 
configured to do so).
Creating the definition files for these is up to you though.
Also, these are not used for formatting while typing, only on saving or 
explicit request. Except if you use clang-format and try the new experimental 
ClangFormat plugin (instead of Beautifier), which has the feature of formatting 
while typing in Qt Creator 4.9.

Br, Eike

> I don't see anything here:
> 
>   https://doc.qt.io/qtcreator/creator-code-style-settings.html
> 
> Thanks!
> 
> ---
> Andy Maloney  //  https://asmaloney.com
> twitter ~ @asmaloney
> 
> _______________________________________________
> Qt-creator mailing list
> Qt-creator@qt-project.org
> https://lists.qt-project.org/listinfo/qt-creator

-- 
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.zil...@qt.io
http://qt.io
Geschäftsführer: Mika Pälsi,
Juha Varelius, Mika Harjuaho
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 
144331 B

_______________________________________________ Qt-creator mailing list 
Qt-creator@qt-project.org https://lists.qt-project.org/listinfo/qt-creator 

_______________________________________________
Qt-creator mailing list
Qt-creator@qt-project.org
https://lists.qt-project.org/listinfo/qt-creator

Reply via email to