Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I change my eclipse source formatter settings to handle the following example?

Tags:

java

eclipse

I writed this code in eclipse

protected void createTables(SQLiteDatabase db) {
        db.execSQL(
                                          "create table " + CUSTOMERS_TABLE +" (" +                     
                        CustomerId + " text primary key," +
                        FirstName + " text," +
                        MiddleName + " text," +
                        LastName + " text," +
                        Portrait + " BLOB," +
                        Gender + " integer," +
                        Age + " integer," +
                        Passed + " integer"+
                ");"

but when I formatted my code using source->format eclipse make them like this

protected void createTables(SQLiteDatabase db) {
        db.execSQL("create table " + CUSTOMERS_TABLE + " (" + CustomerId
                + " text primary key," + FirstName + " text," + MiddleName
                + " text," + LastName + " text," + Portrait + " BLOB," + Gender
                + " integer," + Age + " integer,"
                + Passed
                + " integer" +");"

I want eclipse formatter keeps my code as it. What are the settings that I should set?

like image 364
Mohammad Moneer Avatar asked Nov 25 '25 12:11

Mohammad Moneer


1 Answers

enclose the line you don't want eclipse to reformat between // @formatter:off and // @formatter:on:

protected void createTables(SQLiteDatabase db) {
    // @formatter:off
    db.execSQL(
                                      "create table " + CUSTOMERS_TABLE +" (" +                     
                    CustomerId + " text primary key," +
                    FirstName + " text," +
                    MiddleName + " text," +
                    LastName + " text," +
                    Portrait + " BLOB," +
                    Gender + " integer," +
                    Age + " integer," +
                    Passed + " integer"+
            ");"
    // @formatter:on
like image 54
JB Nizet Avatar answered Nov 27 '25 03:11

JB Nizet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!