How do I autoindent in Netbeans?
Open Tools -> Options -> Keymap, then look for the action called "Re-indent current line or selection" and set whatever shortcut you want.
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.