Page 1 of 1

[SOLVED] Code Formatter - indent access modifiers in class

Posted: Thu Sep 08, 2016 2:01 pm
by mnemonic
Hi. I've just started using CodeLite IDE recently and am stuck on trying to get C++ formatting configured the way I like it, which is like this:

Code: Select all

class Foo
{
  private:
    int some_int;

  public:
    Foo();
    ~Foo(); 
};
I'd like the access modifiers (public, protected, private) indented like above, but cannot for the life of me figure out how to achieve this in CodeLite.

Any help would be appreciated.

Re: Code Formatter - indent access modifiers in class

Posted: Thu Feb 23, 2017 6:30 am
by mnemonic
I'm trying to do exactly the same thing, but have thus far been unsuccessful. I have read "clang formatting" documentation here:

http://clang.llvm.org/docs/ClangFormatStyleOptions.html

I went ahead and installed "clang-format" (sudo apt install clang-format) and then ran the command:

Code: Select all

clang-format -style=llvm -dump-config > .clang-format
to generate a .clang-format file (which I then placed in my project's root directory). I then opened this file and edited the AccessModiferOffer:

AccessModifierOffset: 2

but this didn't work for me. Sometimes it just doesn't change anything, sometimes it ends up deleting the code in my files, and once I got this:

Code: Select all

class MyClass
{
  public:
  MyClass();
  ~MyClass();
};

Re: Code Formatter - indent access modifiers in class

Posted: Thu Feb 23, 2017 1:19 pm
by eranif
If you want to use .clang-format file, you should tell CodeLite about it.
This is done from: Plugins->Source Code Formatter->C++->clang-format->Style->File

You should place this file in the workspace folder

Eran

Re: Code Formatter - indent access modifiers in class

Posted: Thu Feb 23, 2017 11:31 pm
by mnemonic
"File" is not an option in Plugins->Source Code Formatter->C++->clang-format->Style->File. I'm using CodeLite version 9.2.0.

Re: Code Formatter - indent access modifiers in class

Posted: Fri Feb 24, 2017 9:24 am
by eranif
then you should upgrade your CodeLite version

Re: [SOLVED] Code Formatter - indent access modifiers in cla

Posted: Sun Feb 26, 2017 1:57 am
by mnemonic
Many thanks eranif - that solved my issue.