Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有时我喜欢不均匀地分隔表达式。例如,我更喜欢...
x*x + y*y
...至...
x * x + y * y
Eclipse 格式化程序似乎不允许这样做。我可以告诉它在每个运算符周围放置零个或一个空格,但我看不出如何让它在我写它时留下空格。这可以做到吗?(@formatter:off太打扰了。)
@formatter:off
不,格式化程序无条件地格式化。
去:
Window -> Preference -> Java -> Code Style -> Formatter -> Edit -> White Space -> Expressions -> Operators
然后选中以下 2 个复选框:
☑ before binary operators ☑ after binary operators