Index: /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java
===================================================================
--- /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java	(revision 27)
+++ /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/EbnfFormatterVisitor.java	(revision 28)
@@ -2,4 +2,5 @@
 
 import java.util.ArrayList;
+import java.util.Stack;
 
 import org.eclipse.emf.ecore.EObject;
@@ -48,4 +49,7 @@
 	private String formattedTextNoWhitespaces;
 	private String originalTextNoWhitespaces;
+	private int newLineOffsetCounter = 0;
+	private int rightHandSideRuleOffset = 0;
+	private Stack<Integer> ruleSpacingStack = new Stack<Integer>();
 	
 	public EbnfFormatterVisitor(EObject rootNode, FormatterConfig config) {
@@ -263,8 +267,16 @@
 	private void text(String str) {
 		buf.append(str);
+		newLineOffsetCounter += str.length();
 	}
 
 	private void space() {
 		buf.append(" ");
+		newLineOffsetCounter++;
+	}
+	
+	private void spaces(int count) {
+		for (int i=0; i < count; i++) {
+			buf.append(" ");
+		}
 	}
 
@@ -350,8 +362,10 @@
 	protected void visitBefore(GroupedSequence node) {
 		text("(");
+		ruleSpacingStack.push(newLineOffsetCounter);
 	}
 
 	protected void visitAfter(GroupedSequence node) {
 		text(")");
+		ruleSpacingStack.pop();
 	}
 
@@ -378,12 +392,15 @@
 	protected void visitBefore(OptionalSequence node) {
 		text("[");
+		ruleSpacingStack.push(newLineOffsetCounter);
 	}
 
 	protected void visitAfter(OptionalSequence node) {
 		text("]");
+		ruleSpacingStack.pop();
 	}
 
 	protected void visitBefore(RepeatedSequence node) {
 		text("{");
+		ruleSpacingStack.push(newLineOffsetCounter);
 	}
 
@@ -392,4 +409,5 @@
 		if (node.isMorethanonce())
 			text("+");
+		ruleSpacingStack.pop();
 	}
 
@@ -400,8 +418,13 @@
 		lastWasSectionHeading=false;
 
+		newLineOffsetCounter = 0;
+
 		if (node.getRulenumber() > 0)
 			text(node.getRulenumber() + ". ");
 		
 		text(node.getName() + " ::= ");
+		
+		rightHandSideRuleOffset = newLineOffsetCounter;
+		ruleSpacingStack.push(newLineOffsetCounter);
 	}
 
@@ -409,4 +432,5 @@
 		text(";");
 		newLine();
+		ruleSpacingStack.pop();
 	}
 
@@ -443,7 +467,19 @@
 
 	protected void visitAfter(SingleDefinition node) {
-		if (!isLastElement())
+		if (!isLastElement()) {
 			text(" | ");
-		
+			if (config.isNewLineAfterAlternative()) {
+				if (config.isPreventNewLineAfterAlternativeOnLessThanThreeElements()) {
+					DefinitionList definitionList = (DefinitionList) node.eContainer();
+					if (definitionList.eContents().size() > 2) {
+						newLine();
+						spaces(ruleSpacingStack.peek());
+					}
+				} else {
+					newLine();
+					spaces(ruleSpacingStack.peek());
+				}
+			}
+		}
 	}
 
Index: /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterConfig.java
===================================================================
--- /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterConfig.java	(revision 27)
+++ /trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/formatter/FormatterConfig.java	(revision 28)
@@ -2,58 +2,22 @@
 
 public class FormatterConfig {
-	private boolean useSpaces = true; // false=tabs, true=whitespaces
-	private int lineWrap = 80; // line in which the output should be wrapped
-	private boolean emptyLineBetweenRules = false;
-	private boolean emptyLineAfterMultiLineRule = false;
-	private boolean emptyLineBeforeSection = true;
-	private boolean emptyLineAfterSection = true;
+	private boolean newLineAfterAlternative = true;
+	private boolean preventNewLineAfterAlternativeOnLessThanThreeElements = true;
 
-	public boolean isUseSpaces() {
-		return useSpaces;
+	public boolean isNewLineAfterAlternative() {
+		return newLineAfterAlternative;
 	}
 
-	public void setUseSpaces(boolean useSpaces) {
-		this.useSpaces = useSpaces;
+	public void setNewLineAfterAlternative(boolean newLineAfterAlternative) {
+		this.newLineAfterAlternative = newLineAfterAlternative;
 	}
 
-	public int getLineWrap() {
-		return lineWrap;
+	public boolean isPreventNewLineAfterAlternativeOnLessThanThreeElements() {
+		return preventNewLineAfterAlternativeOnLessThanThreeElements;
 	}
 
-	public void setLineWrap(int lineWrap) {
-		this.lineWrap = lineWrap;
-	}
-
-	public boolean isEmptyLineBetweenRules() {
-		return emptyLineBetweenRules;
-	}
-
-	public void setEmptyLineBetweenRules(boolean emptyLineBetweenRules) {
-		this.emptyLineBetweenRules = emptyLineBetweenRules;
-	}
-
-	public boolean isEmptyLineAfterMultiLineRule() {
-		return emptyLineAfterMultiLineRule;
-	}
-
-	public void setEmptyLineAfterMultiLineRule(
-			boolean emptyLineAfterMultiLineRule) {
-		this.emptyLineAfterMultiLineRule = emptyLineAfterMultiLineRule;
-	}
-
-	public boolean isEmptyLineBeforeSection() {
-		return emptyLineBeforeSection;
-	}
-
-	public void setEmptyLineBeforeSection(boolean emptyLineBeforeSection) {
-		this.emptyLineBeforeSection = emptyLineBeforeSection;
-	}
-
-	public boolean isEmptyLineAfterSection() {
-		return emptyLineAfterSection;
-	}
-
-	public void setEmptyLineAfterSection(boolean emptyLineAfterSection) {
-		this.emptyLineAfterSection = emptyLineAfterSection;
+	public void setPreventNewLineAfterAlternativeOnLessThanThreeElements(
+			boolean preventNewLineAfterAlternativeOnLessThanThreeElements) {
+		this.preventNewLineAfterAlternativeOnLessThanThreeElements = preventNewLineAfterAlternativeOnLessThanThreeElements;
 	}
 
