简体   繁体   中英

How do I stop Eclipse's format from messing up my code?

For some reason Eclipse has started messing up my code when I CTRL + SHIFT + F to format. Any line longer than 80 characters is getting wrapped, and lines with comments at the end really get messed up.

Before CTRL + SHIFT + F :

projectile.setPosition((CAMERA_WIDTH / 2) - (projectile.getWidth() / 2), 800);//projectile center is set to middle of screen at bottom

After CTRL + SHIFT + F :

    projectile.setPosition(
            (CAMERA_WIDTH / 2) - (projectile.getWidth() / 2), 800);// projectile
                                                                    // center
                                                                    // is
                                                                    // set
                                                                    // to
                                                                    // middle
                                                                    // of
                                                                    // screen
                                                                    // at
                                                                    // bottom

In Window > Preferences > General > Editors > Text Editors my Print margin column is set to 150 and that is the only preference I have changed. Even when I restore defaults Eclipse still messes up my code.

How do I change this feature?

Just adjust the formatter settings to your personal preferences and gusto and you are set. There are LOTS of options and line wrap and line width are some of them

The preference you want is under Window > Preferences > Java > Code Style > Formatter . Edit the profile, go to the Line Wrapping tab, and set the Maximum line width .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM