3

Some IDEs offer the feature to automatically format a line or block of code after finishing it e.g. by writing the closing curly or semicolon. I find it hard to believe that IDEA does not offer this kind of feature. Or does it?

If you know how to turn it on - or if I maybe need some plugin - let me and the world know, please!

Christoph Grimmer
  • 4,210
  • 4
  • 40
  • 64

2 Answers2

4

If it's a single line, you can use the Complete Current Statement action (which adds a closing bracket, semi-colon, and so on) with ctrl-shift-enter - this seems to reformat the whole line.

Otherwise, you can obviously rebind ctrl-w and ctrl-alt-l (to reformat selected text) or just ctrl-alt-l (reformat whole file) to faster / easier keybindings so that you can quickly reformat whenever you want to.

vikingsteve
  • 38,481
  • 23
  • 112
  • 156
2

There is no automatic reformat feature, related requests:

See also my answer to the similar question with the Complete Current Statement workaround.

Community
  • 1
  • 1
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904