Autoformat line when hit enter
Hi!
How can I do auto-format line when I hit enter or type ";" ?
E.g. I typed
var a:SomeClass=new SomeClass(q,w,e,r);
And when I end this line I want to get
var a:SomeClass = new SomeClass(q, w, e, r);
Please sign in to leave a comment.
I do not believe there is a way to do this. You can open a feature request asking for such an option: http://youtrack.jetbrains.com
In the meantime, the closest thing is the Complete Current Statement action. (By default it is mapped to Ctrl+Shift+Enter / ⌘⇧⏎). This will complete the current line and format it.It does not take you to the next line. But a second hitting of it will. In addition to formatting the line, it will add any necessary items such as completing any unbalanced parenthesis, adding semicolons, etc. For example, if I start with:
Where '|' is my curosr, and I hit enter, I end up with:
And typing that a second time, or hitting Enter, will move me to the next line.
I suppose you could remap the Enter key from the Enter action and over to the Complete Current Statement action. You'd get close to what you want. But would need to always hit enter twice. And I'm not sure what other strangeness or awkward UI experience you might get.