在Eclipse中对齐多行Java字符串 [英] Aligning multiline Java strings in Eclipse
问题描述
字符串
的赋值,如下所示: (安装)< - [:CURRENT] - (计算机名称)字符串cypher =可选匹配(更新:更新{名称:{名称}}),
+(更新) - [:INSTALLED_IN] :COMPUTER {name:{computerName}})
+RETURN更新,安装,电脑;
我希望在使用 Ctrl + Shift + F 并生成以下代码,所有 +
符号很好地在 = $ c下对齐
$ b $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $' $ b +(update) - [:INSTALLED_IN] - >(installation)< - [:CURRENT] - (computer:COMPUTER {name:{computerName}})
+RETURN更新,电脑;
我该如何做到这一点?
我使用了我导入到Eclipse中的这个formatter.xml文件: http://pastebin.com/iThW8Lub 也许这里需要一些调整?
在Eclipse中使用格式化程序设置,并不能正确地 所要找的。我怀疑这是不可能的给定的格式化设置(然而,你可以找到或写一个插件,将做你想做的)。 那是说,我能够实现两个选项,是最接近你正在寻找的。 这是为开普勒的Eclipse: 转至 现在选择你喜欢的包装策略。这将影响包装前每行的元素数量。我会用 缩进政策,选择 现在,您可以选择/取消选中 在我看来,效果1虽然不太整洁,但更具可读性,但是这完全取决于你。 希望这有助于!你总是有手动的代码格式来回落=) I'm a little new with the Eclipse formatter system. Given an assignment to I wish to have Eclipse format it when hitting Ctrl+Shift+F and produce the following, with all How can I achieve that? I'm using this formatter.xml file which I've imported into Eclipse: http://pastebin.com/iThW8Lub Maybe some tweak here is needed? I played around with the formatter settings in Eclipse, and was not able to achieve exactly what you are looking for. I suspect that it is not possible with the given formatter settings (you could, however, find or write a plug-in that will do what you want). That being said, I was able to achieve two options that are the closest to what you are looking for. This is for Eclipse Kepler: Go to Now choose the wrapping policy you prefer. This will affect the number of elements on each line before the wrapping. I go with For indentation policy, choose Now, you can choose to check/uncheck
首选项> Java>代码样式>格式化器
。点击编辑
您的个人资料。转到换行
选项卡。选择表达式
。对于换行策略
选择不换行
。现在展开表达式
列表并选择二进制表达式
。
>在需要的时候换行</ code>,但是您可以选择将每个元素放在一个单独的行中。
列上的缩进
。
在操作符
之前换行,这将分别为您生成效果1和效果2:
$ b $ $ $ $ $ p $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ [:INSTALLED_IN] - >(installation)< - [:CURRENT] - (computer:COMPUTER {name:{computerName}})
+RETURN update,installation,computer;
效果2:[]在运算符之前换行
< (更新:UPDATE {name:{name}}),+
(update) - [:INSTALLED_IN] - >(安装)< - [:CURRENT] - (computer:COMPUTER {name:{computerName}})+
RETURN update,installation,computer;
String
over a couple of lines like this:String cypher = "OPTIONAL MATCH (update:UPDATE {name: {name}}),"
+ "(update)-[:INSTALLED_IN]->(installation)<-[:CURRENT]-(computer:COMPUTER {name: {computerName}})"
+ "RETURN update, installation, computer";
+
signs aligning nicely under =
:String cypher = "OPTIONAL MATCH (update:UPDATE {name: {name}}),"
+ "(update)-[:INSTALLED_IN]->(installation)<-[:CURRENT]-(computer:COMPUTER {name: {computerName}})"
+ "RETURN update, installation, computer";
Preferences > Java > Code Style > Formatter
. Click to Edit
your profile. Go to the Line Wrapping
tab. Select Expressions
. For Line wrapping policy
select Do not wrap
. Now expand the Expressions
list and select Binary Expressions
.Wrap when necessary
, but you could choose to have every element on a separate line.Indent on column
.Wrap before operator
, which will give you Effect 1 and Effect 2 respectively:Effect 1: [x] Wrap before operator
String cypher = "OPTIONAL MATCH (update:UPDATE {name: {name}}),"
+ "(update)-[:INSTALLED_IN]->(installation)<-[:CURRENT]-(computer:COMPUTER {name: {computerName}})"
+ "RETURN update, installation, computer";
Effect 2: [ ] Wrap before operator
String cypher = "OPTIONAL MATCH (update:UPDATE {name: {name}})," +
"(update)-[:INSTALLED_IN]->(installation)<-[:CURRENT]-(computer:COMPUTER {name: {computerName}})" +
"RETURN update, installation, computer";
In my opinion, Effect 1, while less neat, is more readable, and that's the one I go with, but it's totally up to you.
Hope this helps! You always have manual code formatting to fall back on =)
这篇关于在Eclipse中对齐多行Java字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!