开发者

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

开发者 https://www.devze.com 2023-03-11 14:29 出处:网络
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.

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 Ec开发者_开发百科lipse 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消