Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij IDEA, format all code in a project

People also ask

How do I select all codes in IntelliJ?

Press Ctrl+Alt+Shift+J to select all case-sensitively matching words or text ranges in the document.

What is code cleanup in IntelliJ?

tip. You can also run code cleanup using the command-line utility. JetBrains Rider allows you to apply formatting and other code style preferences in a bulk mode to instantly eliminate code style violations in one or more files, in a project or in the entire solution.


In the tree-structure, right click on the folder you like to reformat, choose "Reformat code" from the menu.


Choose the "whole project" radio button instead of the individual file when you ask to reformat.

Just be aware of one problem: If you're working on a larger project with other developers who don't conform to your style, and you're using IntelliJ to transform all their code every time you edit it, you might be causing a problem with your version control system. It will long a huge volume of changes when you check in, and few of them will have anything to do with changing functionality. Better to conform to the group style in that case.


According the iDea: Editor basics documentation:

You can use the shortcut Ctrl+ALT+L (Windows/Linux) or ⌥⌘+L (MAC OS X) and select the Rearrange entries option to reformat the code in the current file or reformat a module or directory (after selecting more than one file).

You can also Right-click a module, file, or directory from the context menu and select Reformat Code and also select the Rearrange entries option.

enter image description here

You can also optimize the imports of your files by selecting the Optimize imports option.

Is some Linux versions the shortcut Ctrl+ALT+L can lock the screen, so you will need to Right-click a file or directory from the context menu and select Reformat Code and also select the Rearrange entries option.

This works for most of the Jetbrains IDES (iDea, PyCharm, WebStorm, RubyMine, and so on.)


"CTRL + ALT + L" work only windows. "CTRL + ALT + L" is Ubuntu Lock screen shortcut key so its not working for this.

Try ,

Right click on the folder you like to reformat, choose "Reformat code" from the menu or click "Code" button on navigation bar in top, choose "Reformat code"

Thank you