[SOLVED] Code Formatter - indent access modifiers in class

Post here any ideas/problems/suggestions you have regarding CodeLite's CodeFormatter (AStyle) plugin
mnemonic
CodeLite Enthusiast
Posts: 12
Joined: Thu Sep 08, 2016 1:45 pm
Genuine User: Yes
IDE Question: C++
Contact:

[SOLVED] Code Formatter - indent access modifiers in class

Post 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.
Last edited by mnemonic on Sun Feb 26, 2017 1:54 am, edited 1 time in total.
mnemonic
CodeLite Enthusiast
Posts: 12
Joined: Thu Sep 08, 2016 1:45 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Code Formatter - indent access modifiers in class

Post 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();
};
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Code Formatter - indent access modifiers in class

Post 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
Make sure you have read the HOW TO POST thread
mnemonic
CodeLite Enthusiast
Posts: 12
Joined: Thu Sep 08, 2016 1:45 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Code Formatter - indent access modifiers in class

Post 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.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Code Formatter - indent access modifiers in class

Post by eranif »

then you should upgrade your CodeLite version
Make sure you have read the HOW TO POST thread
mnemonic
CodeLite Enthusiast
Posts: 12
Joined: Thu Sep 08, 2016 1:45 pm
Genuine User: Yes
IDE Question: C++
Contact:

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

Post by mnemonic »

Many thanks eranif - that solved my issue.
Post Reply