How do I autoindent in Netbeans?

Elazar Leibovich picture Elazar Leibovich · Aug 21, 2009 · Viewed 277.2k times · Source

In eclipse you can click Ctrl+I at any line, and it'll automatically indent the line or group of lines according to the indentation scheme you chose in the settings.

I'm really missing this feature in Netbeans. Is there any equivalent feature?

I'm aware of Alt+Shift+F but it's not good enough. I want to indent a group of lines, and not all the file.

Answer

Manu Manjunath picture Manu Manjunath · Mar 22, 2012

Shortcut:

  • Windows: Alt+Shift+F
  • Mac OS X: Ctrl+Shift+F (note: it's Ctrl and not )

On using above shortcut, NetBeans indents your selection. If nothing's selected, it indents the whole file.

You can even format multiple files/folders at a time! In the Projects window/sidebar, if you select one or more folders or files and use the shortcut, NetBeans asks "Recursively format selected files and folders?". Pressing OK will recursively format all the selected files/folders.

Above shortcuts works on NetBeans from versions 7 to 12.