Search code examples
c++classcodelite

Auto insert semicolon after class definition in Codelite


When writing classes in Codelite, I get this annoying behaviour where the IDE doesn't insert a semicolon after the closing brace, which has resulted in a few annoying syntax errors when compiling.
I tried looking in the program's Preferences menu but couldn't find a relevant option and Google didn't help either in this respect.
Is there any option at all to enable the auto-insertion of a semicolon after a class declaration?


Solution

  • CodeLite does not do that by default and there is no setting that you can modify to do that.

    You can however, achieve this in two other ways:

    Use the class wizard:

    Create your class using the 'Class Wizard': Right click on a folder in the tree view and select New class

    Use the abbreviations plugin

    • From the menu bar: plugins->abbreviations->settings
    • Click on the new entry button (green plus icon)
    • Name it "class" (or a name of your choice) and paste the following code:

      class | { public:

      };

    • Click "Save"

    • Now when typing in the editor class hit: Ctrl-ENTER and you will see this entry - select it and it will added to the text editor for you.

    NOTE: the | marker indicates where CodeLite will place the caret, You can have multiple carets. So the above example can be expanded to something like this:

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

    Now, when CodeLite adds this snippet to the editor, you will get 3 carets. Typing the class name will add them in all three locations

    NOTE 2: The above was tested using CodeLite 11.0.8 (git latest), but it should work with CodeLite 11.0 as well

    HTH,

    Eran, Author of CodeLite IDE