关闭所选代码区域的 Eclipse 格式化程序?
当我 ctrl+shift+f 启动项目代码时,它在任何地方都很好地完成了工作。
但它弄乱了 CSS,特别是那些过滤器部分并添加了一堆空格。
另外,如何指定 Java 代码的某些部分不被该命令格式化?
When I ctrl+shift+f up the project code, its doing its job just fine, everywhere.
But its messing the CSS, specially those filter parts and adding bunch of spaces.
Also how do I specify some portion of Java code to not be formated by that command ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要防止 Java 代码的特定部分被格式化,请转到“Window > Preferences > Java > Code Style > Formatter”。单击“编辑...”按钮,转到“关闭/打开标签”选项卡并启用标签。之后,您可以简单地将这些标签嵌入到 Java 代码中以禁用它们之间的格式。如果您不更改默认标签,则会执行类似以下操作:
IIRC,此选项仅自 Eclipse 3.6 起存在。
至于CSS代码,如果你安装了Eclipse WTP,进入“Window > Preferences > Web > CSS Files > Editor”,你会在那里找到一些基本的格式化选项。
To prevent specific portions of Java code from being formatted, go to "Window > Preferences > Java > Code Style > Formatter". Click the "Edit..." button, go to the "Off/On Tags" tab and enable the tags. Afterwards, you can simply embed those tags in Java code to disable the formatting in-between them. If you don't change the default tags, something like this will do :
IIRC, this option only exists since Eclipse 3.6.
As for css code, if you have installed Eclipse WTP, go to "Window > Preferences > Web > CSS Files > Editor" and you will find some basic formatting options there.
您无法在类级别配置格式,但可以在项目级别配置。
要进行配置,请在 eclipse
window->preferences-> 中遵循以下路径: java->代码风格->格式化程序
现在选择配置项目特定设置并进行更改。
You cannot configure the formatting at class level, but you can configure at the project level.
To do the configuration follow this path in eclipse
window->preferences-> java -> code style -> formatter
now select the configure project specific settings and do your changes.