Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reindent lines in IntelliJ IDEA / WebStorm?

In Eclipse, I can select a few lines and press Ctrl + I to reindent those lines. How do I do the same in IntelliJ IDEA / WebStorm?

Note:

  • I don't want to "indent" or "unindent" the selected lines - that would "move" the text to the right or to the left manually. I want the IDE to be clever about how to position the lines.
  • I don't want to reformat anything, i.e. there should be no modifications to characters beyond the first non-whitespace character on every line.
like image 941
Borek Bernard Avatar asked Sep 04 '12 13:09

Borek Bernard


People also ask

How do I Reindent in IntelliJ?

In the Project tool window, right-click a module or a directory and from the context menu, select Reformat Code or press Ctrl+Alt+L . In the dialog that opens, specify the reformatting options and click OK.

How do I align lines in IntelliJ?

Open indentation settings in code style scheme Click the widget and select Configure Indents for 'Language'. In the dialog that opens, you can change settings for tabs and indents and also configure other code style settings. Click OK. Reformat the necessary part of your project to apply new indentation settings.

How do I align code in Webstorm?

In the Settings/Preferences dialog ( Ctrl+Alt+S ), go to Editor | Code Style. Select a language for which you want to create arrangement rules. On the Arrangement tab, specify the appropriate options such as grouping and matching rules. Click OK to save the changes.


2 Answers

Code | Auto-Indent Lines (Ctrl+Alt+I in Windows default keymap).

like image 189
CrazyCoder Avatar answered Sep 19 '22 15:09

CrazyCoder


On a mac, it's Ctrl+Option+I by default.

like image 24
Tad Avatar answered Sep 18 '22 15:09

Tad