The formatting shortcuts in Intellij IDEA are :

  • For Windows : Ctrl + Alt + L
  • For Ubuntu : Ctrl + Alt + Windows + L
  • For Mac : ⌥ (Option) + ⌘ (Command) + L
Answer from axelrod on Stack Overflow
🌐
JetBrains
jetbrains.com › help › idea › reformat-and-rearrange-code.html
Reformat code | IntelliJ IDEA Documentation
3 weeks ago - Reformat your code (Ctrl+Alt+L). IntelliJ IDEA will reformat your code in accordance with the current style settings, keeping existing formatting for the rules which you've selected.
Discussions

"Reformat Code" can not be called via the shortcut "⌘⌥L"
Review its shortcut in settings. More on reddit.com
🌐 r/Jetbrains
5
6
November 21, 2024
Intellij finally has a built in "Reformat code and organize imports" save action in 2021.2

It automatically saves, so usually I just use the reformat code shortcut (rather than using save and have auto format in other IDEs)

More on reddit.com
🌐 r/IntelliJIDEA
4
16
July 28, 2021
What are your most popular keyboard shortcuts in IntelliJIDEA?
I'm speaking for Mac's keybindings, I'm sure you can find Windows equivalents. CMD+Option+V/P/F/C/M for various extractions (with possible finding of duplicates): CMD+Option+V to extract expression into variable CMD+Option+P to extract extperssion into parameter CMD+Option+F to extract expression to field CMD+Option+C to extract expression into constant (e.g. static final in Java) CMD+Option+M to extract valid code block into method CMD+T to "update" project from VCS (e.g. git pull) CMD+K to open dialog/sidebar to commit files CMD+Shift+K to push changes (with dialog) CMD+F2 to stop running program(s) Control+R to run last Run configuration Control+D to debug last Run configuration Control+Shift+R/D to run/debug runnable code block (e.g. @Test method, or static void main) (cursor needs to be on method header or body) CMD+Backspace to delete current line Shift+F6 to rename F5 to copy current file (with full-supported rename) F6 to move current file (On selected text): Control+G to multi-cursor select instances of selected text (press many times as needed). Add Shift to unselect last selected text. Option+UP/Down: shrink/expand selection a.k.a "smart selection" CMD+E show recent files (press again to show revent files that are changed) CMD+1/2/3... focus/open/hide windows: 1 - project window, 4 - run window, 5 - debug window CMD+O go to class (press again to search all classes, including outside of your project, e.g. in libs) CMD+Shift+O go to file (same for "press again" as above) CMD+F12 find methods, classes and other symbols for current file CMD+B go to declaration CMD+L go to line F2 go to next error (or warning if there are no errors). Shift+F2 for previous error/warning. Shift+Shift (2x shift): Search everywhere (useful for actions/settings, can find classes/files, but it is better to use CMD+[Shift]+O for that) And many many more. I've listed here some that came first on my mind and which I use frequently. I'm sure I forgotten many more. You can use this reference card (pdf) for commonly used shortcuts (Win+Linux+Mac): https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf . You can use 'Key Promoter X' plugin to fast learn shortcuts being used (e.g. if you mouse-click something, Key Promoter will show you a notification with shortcut for that action). For postfix completion, you can install plugin with the same name where you can create your own postix templates. Besides templates already mentioned, I use .return to put "return" in front of current line, with ; on end .new to invoke constructor (e.g. Clazz.new -> new Clazz) .not to negate expression, comes handy before .if .field to create field .arg to put expression as argument .cast and .castvar to cast expression / create new variable with cast expression .try for try catch Postfix completion can be invoked with CMD+J. Hope it helps. More on reddit.com
🌐 r/IntelliJIDEA
35
49
January 4, 2021
Essential IntelliJ Shortcuts

My favorite is ALT + J for select next occurrence. Multicursor is crazy useful. Once you get good with arrowkeys + modifiers and home/end it makes creating/editing stuff with the same pattern much easier.

More on reddit.com
🌐 r/java
54
212
April 29, 2019
🌐
JetBrains
blog.jetbrains.com › home › intellij idea › how to format java code
How to Format Java Code - The JetBrains Blog
June 6, 2024 - While coding with IntelliJ IDEA, we don’t need to manually format our code, as the IDE does it automatically. For example, if we press Enter (Windows/Linux) or ⏎ (macOS), the caret goes into the correct place for us to start typing. The same is true if we use other shortcuts like Shift+Enter (Windows/Linux) or ⇧⏎ (macOS) to move to the next line, or if we use code generation.
🌐
JetBrains
jetbrains.com › guide › java › tutorials › reading-code › formatting
Formatting - JetBrains Guide
March 1, 2024 - If we encounter code that is not properly formatted, we can have IntelliJ IDEA reformat the code for us. In the file you want to reformat, use the shortcut ⌘⌥L (macOS) / Ctrl+Alt+L (Windows/Linux).
🌐
JetBrains
jetbrains.com › guide › tips › reformat-code-or-file
Reformat Your Code - JetBrains Guide
June 12, 2024 - Lastly, there are additional settings you can use for reformatting your code which you can access by invoking the "Reformat Code Dialog" ⌘⌥⇧L (macOS) / Ctrl+Alt+Shift+L (Windows/Linux).
🌐
Reddit
reddit.com › r/jetbrains › "reformat code" can not be called via the shortcut "⌘⌥l"
r/Jetbrains on Reddit: "Reformat Code" can not be called via the shortcut "⌘⌥L"
November 21, 2024 -

If I open IntelliJ IDEA 2024.3 (Ultimate Edition) on macOS ⌘⌥L to reformat code works at first. After a while it stops working. After it stops working I still can reformat code via the Menubar.

Any thoughts?

Find elsewhere
🌐
Medium
hirosht.medium.com › automatically-reformat-code-on-save-in-intellij-ddf7842801e0
Automatically reformat code on save in IntelliJ - Hirosh Tharaka - Medium
July 12, 2023 - Automatically reformat code on save in IntelliJ Configure the IDE to reformat code in modified files automatically when your changes are saved. Press Ctrl+Alt+S to open the IDE settings select Tools …
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 207032465-Reformat-code-Ctrl-Alt-L-is-not-working
Reformat code Ctrl+Alt+L is not working – IDEs Support (IntelliJ Platform) | JetBrains
April 19, 2005 - >> Recently I upgraded to IntelliJ from that time , when I do ctrlaltL >> for reformat, it is not working. But it works fine when I do it using >> menu bar going to tools and clicking on reformat code.
🌐
Reddit
reddit.com › r/intellijidea › intellij finally has a built in "reformat code and organize imports" save action in 2021.2
r/IntelliJIDEA on Reddit: Intellij finally has a built in "Reformat code and organize imports" save action in 2021.2
July 28, 2021 -

Intellij finally implemented a feature that other IDEs had for years. You can now finally set up Intellij to automatically reformat your code and organize your imports on each save. There is no more need to either download the "Save Actions plugin" or to write your own macro to execute these two commands on each save. It was about effin' time.

🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360008191759-Reformat-Code-Shortcut-Option-Command-L-Conflicts-in-Mac
Reformat Code Shortcut (Option-Command-L) Conflicts in Mac – IDEs Support (IntelliJ Platform) | JetBrains
Hi, Using IntelliJ Idea in Mac with classic keyboard binding, I'm unable to use Reformat Code with default shortcut Option-Command-L. Apparently it's conflicting with a Mac shortcut so that pressin...
🌐
Claude Code Docs
code.claude.com › platforms and integrations › jetbrains ides
JetBrains IDEs - Claude Code Docs
2 weeks ago - Use Claude Code with JetBrains IDEs including IntelliJ, PyCharm, WebStorm, and more
🌐
Visual Studio Code
code.visualstudio.com › docs › configure › keybindings
Keyboard shortcuts for Visual Studio Code
November 3, 2021 - Customize keyboard shortcuts in Visual Studio Code, including keybinding rules, command arguments, chords, and system-wide shortcuts.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 16728798920338--Optimize-Imports-and-Reformat-Code-functions-do-not-adhere-to-my-configured-settings
'Optimize Imports' and 'Reformat Code' functions do not adhere to my configured settings. – IDEs Support (IntelliJ Platform) | JetBrains
January 31, 2024 - However, when using the 'Optimize Imports' feature (shortcut CTRL + SHIFT + L), it does not adhere to these custom import settings. Manually copying and pasting imports is necessary to comply with the format conventions. I'm currently using Ubuntu 20.04 LTS, and my IntelliJ Ultimate version ...
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 207280009-Paste-without-auto-formatting
Paste without auto-formatting – IDEs Support (IntelliJ Platform) | JetBrains
August 3, 2016 - As Andriy mentioned, 'Paste simple', whose hotkey is 'Ctrl+Alt+Shift+V', will preserve the literal whitespace and formatting of the pasted text.
🌐
JetBrains
jetbrains.com › guide › java › tutorials › reformatting-code › reformatting-a-selection-or-class
Reformatting a selection of code or class - JetBrains Guide
February 17, 2023 - You can use ⌘⌥L (macOS) / Ctrl+Alt+L (Windows/Linux) to reformat a selection of code according to your reformat settings. Let's press ⌘⌥L (macOS) / Ctrl+Alt+L (Windows/Linux) in the class that contains this horribly formatted ...
🌐
ChatGPT Learn
developers.openai.com › codex › ide
Codex IDE extension | ChatGPT Learn
Codex starts with the code you are already looking at, so you spend less time restating the problem.
🌐
Medium
medium.com › nerd-for-tech › auto-format-code-in-android-studio-intellij-idea-1f0450ee44a3
Format java kotlin code automatically after saving a file using Intellij IDEA | Medium
June 10, 2021 - Press ⌥⌘L to reformat code (Code | Reformat Code ). Then press ⌘S to save all changes (File | Save All ). Android Studio/IntelliJ IDEA will show the performed actions in the status bar.
🌐
JetBrains
blog.jetbrains.com › home › intellij idea › 30 days with intellij idea. code style and formatting
30 Days with IntelliJ IDEA. Code Style and Formatting - The JetBrains Blog
July 24, 2013 - Just press Alt + Ctrl + I (Alt + Cmd + I for Mac) shortcut and it will quickly fix indents for the current line. Read the complete article to learn more on the code style and formatting ...
🌐
YouTube
youtube.com › shorts › DX5C19cmX9o
IntelliJ IDEA coding tips - reformat - YouTube
#intellijidea #intellij #java #jetbrains #programming #shorts
Published: November 24, 2023