How do I write an eclipse plugin to format C ++ 14 source code?

In eclipse CDT, you can press Ctrl+ Shift+ Fto format the C ++ 14 source code in the current editor.

However, there are some annoying bugs in the default CDT format. So I want to write my own formatter. I know it's not easy to write non-trivial, but I have a powerful tool: clang-format .

Using clang-format will be as easy as writing a C ++ 14 source code formatter as homework. However, the real hurdle is building an eclipse plugin. I just want to overload the default handler Ctrl+ Shift+ F.

How to achieve the goal?

+3


source to share


1 answer


I want to share an Eclipse plugin named CppStyle . http://wangzw.github.io/CppStyle/

CppStyle integrates clang-format as another code formatting for Eclipse CDT and supports formatting C / C ++ code with Ctrl

+ Shift

+ F

. In addition, you can enable CDT to format the original file on save.



CppStyle also integrates cpplint.py to check coding styles. Check and flag the style issues in the CDT editor when the user is about to save the original file.

+3


source







All Articles