Aligning multiline Java strings in Eclipse -


i'm little new eclipse formatter system. given assignment string on couple of lines this:

string cypher = "optional match (update:update {name: {name}}),"         + "(update)-[:installed_in]->(installation)<-[:current]-(computer:computer {name: {computername}})"         + "return update, installation, computer"; 

i wish have eclipse format when hitting ctrl+shift+f , produce following, + 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"; 

how can achieve that?

i'm using formatter.xml file i've imported eclipse: http://pastebin.com/ithw8lub maybe tweak here needed?

i played around formatter settings in eclipse, , not able achieve exactly looking for. suspect not possible given formatter settings (you could, however, find or write plug-in want).

that being said, able achieve 2 options closest looking for.

this eclipse kepler:

go preferences > java > code style > formatter. click edit profile. go line wrapping tab. select expressions. line wrapping policy select do not wrap. expand expressions list , select binary expressions.

now choose wrapping policy prefer. affect number of elements on each line before wrapping. go wrap when necessary, choose have every element on separate line.

for indentation policy, choose indent on column.

now, can choose check/uncheck wrap before operator, give effect 1 , 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 opinion, effect 1, while less neat, more readable, , that's 1 go with, it's totally you.

hope helps! have manual code formatting fall on =)


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -