How do I autoindent in Netbeans?

后端 未结 10 1199
挽巷
挽巷 2020-12-02 05:25

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 i

相关标签:
10条回答
  • 2020-12-02 05:56

    Shift + Alt + F indents the whole file.

    0 讨论(0)
  • 2020-12-02 05:56

    I have netbeans 6.9.1 open right now and ALT+SHIFT+F indents only the lines you have selected.

    If no lines are selected then it will indent the whole document you are in.

    1 possibly unintended behavior is that if you have selected ONLY 1 line, it must be selected completely, otherwise it does nothing. But you don't have to completely select the last line of a group nor the first.

    I expected it to indent only one line by just selecting the first couple of chars but didn't work, yea i know i am lazy as hell...

    0 讨论(0)
  • 2020-12-02 05:57

    If you want auto-indent just like Emacs does it on TAB, i.e. indent the current line and move the cursor to the first non-whitespace character, do this:

    1. Go to Tools -> Options -> Editor -> Macros
    2. Create a new macro and call it something like "tabindent"
    3. Insert the following macro code:

      reindent-line caret-line-first-column caret-begin-line

    4. Click "Set Shortcut" and press TAB

    0 讨论(0)
  • 2020-12-02 06:08

    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.

    0 讨论(0)
提交回复
热议问题