简体   繁体   English

如何阻止 Eclipse 的格式弄乱我的代码?

[英]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.出于某种原因,当我CTRL + SHIFT + F格式化时,Eclipse 开始弄乱我的代码。 Any line longer than 80 characters is getting wrapped, and lines with comments at the end really get messed up.任何超过 80 个字符的行都会被换行,最后带有注释的行真的会被弄乱。

Before CTRL + SHIFT + F :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 :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.Window > Preferences > General > Editors > Text Editors中,我的Print margin column设置为 150,这是我更改的唯一首选项。 Even when I restore defaults Eclipse still messes up my code.即使我恢复默认值 Eclipse 仍然会弄乱我的代码。

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 .您想要的首选项位于Window > Preferences > Java > Code Style > Formatter下。 Edit the profile, go to the Line Wrapping tab, and set the Maximum line width .将配置文件 go 编辑到Line Wrapping选项卡,然后设置Maximum line width

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 java 文件中复制 java 代码而不弄乱格式? - How do you copy java code from a java file from eclipse without messing up the format? 如何阻止Eclipse的自动补全功能建议组合变量名? - How can I stop Eclipse's auto-completion feature from suggesting made up variable names? 当我从 Eclipse 运行我的 MonkeyC 程序时,为什么我的代码更改没有编译或显示? - Why do my code changes not compile or show up when I run my MonkeyC program from Eclipse? 如何从php Eclipse工作区运行代码 - How do I run my code from php eclipse workspace 如何阻止@Unrolled Spock测试在Eclipse Junit View中显示为“Unrooted Tests”? - How do I stop @Unrolled Spock tests from showing up as “Unrooted Tests” in the Eclipse Junit View? 如何在Eclipse中停止“弹出式透视图”? - How do I stop “pop-up perspectives” in Eclipse? 如何阻止eclipse自动启动Android模拟器? - How do I stop eclipse from automatically starting up an android emulator? 停止代码格式以消除eclipse中的空格 - Stop Code Format from removing whitespaces in eclipse 如何阻止Console在Eclipse中自动弹出 - How do you stop Console from popping up automatically in Eclipse 有没有一种方法可以阻止Eclipse(3.7)弄乱内容 <xsd:documentation> 标签? - Is there a way to stop Eclipse (3.7) from messing up content of <xsd:documentation> tags?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM