3

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • This is useful link to solve your problem. [Follow](http://stackoverflow.com/questions/1820908/how-to-turn-off-the-eclipse-code-formatter-for-certain-sections-of-java-code) – Smit Dec 27 '12 at 18:15

1 Answers1

4

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
JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • 1
    @forsubhi This is the solution. Those comment line will turn off auto-formatting for those specific line. [See here](http://stackoverflow.com/questions/1820908/how-to-turn-off-the-eclipse-code-formatter-for-certain-sections-of-java-code) – Smit Dec 27 '12 at 18:11
  • Make sure these tags are enabled in Windows - Preferenced - Java - Code style - Formatter - Edit... - Off/On Tags (that's at least where they are in Indigo). – JB Nizet Dec 27 '12 at 18:54