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
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.
Discussions

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
Reformat code via keyboard shortcut doesn't work in IntelliJ - Stack Overflow
I have a Java project in IntelliJ under Windows. I'm trying to format code by using Ctrl+Alt+L combination, but this does nothing. In case use the menu Code -> Reformat Code the code formats perfectly. ... Save this answer. ... Show activity on this post. Check that your keyboard shortcuts are ... More on stackoverflow.com
🌐 stackoverflow.com
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
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
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 ...
🌐
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 › help › idea › reformat-and-rearrange-code.html
Reformat code | IntelliJ IDEA Documentation
4 weeks ago - If you do not select a code fragment, IntelliJ IDEA will reformat the whole file. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. In the main menu, go to Code | Reformat Code or press Ctrl+Alt+L. Alternatively, on the toolbar that appears, click Reformat Code. Either open your file in the editor and press Ctrl+Alt+Shift+L or in the Project tool window, right-click the file and select Reformat Code.
🌐
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). The options here will vary depending on which type of code you're working with so try it out and see what you can learn! Want to learn more? Check out the in depth reformatting tutorial for IntelliJ IDEA ·
🌐
JetBrains
jetbrains.com › guide › java › tutorials › reformatting-code › reformatting-only-code-youve-changed
Reformatting code you've changed - JetBrains Guide
February 17, 2023 - As we talked about in the previous step, you can use the keyboard shortcut ⌘⌥L (macOS) / Ctrl+Alt+L (Windows/Linux) to reformat a selection of code or the whole class according to your reformatting settings.
Find elsewhere
🌐
IQCode
iqcode.com › code › other › reformat-intellij
reformat intellij Code Example
October 18, 2021 - // Mac CMD + Option + L // Windows Ctrl + Alt + L
🌐
JetBrains
jetbrains.com › help › idea › reformat-file-dialog.html
You will be redirected shortly
August 9, 2022 - You will be redirected shortly · Redirecting… · Click here if you are not redirected
🌐
EDUCBA
educba.com › home › software development › software development tutorials › software development basics › intellij format code
IntelliJ Format Code | How to Create IntelliJ Formatting Code?
February 17, 2023 - ... Yes, we can do it; for that, we need to press the Ctrl+Alt+L, so IntelliJ tries to reformat the written code. ... If we want to reformat the code, use Ctrl+Alt+L; for Ubuntu, we can use Ctrl+Alt+Windows+L.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360000331339-Shortcut-Key-of-Reformat-Code-and-Windows-Lock-Screen
Shortcut Key of Reformat Code and Windows Lock Screen – IDEs Support (IntelliJ Platform) | JetBrains
Do you want to delete post? Answered · styliss · Created July 20, 2018 07:39 · Shortcut Key of Reformat Code and Windows Lock Screen Windows 10 used `Ctrl + Alt + L` to the Lock.
🌐
Websparrow
websparrow.org › home › intellij idea – code reformat and rearrange shortcut keys
IntelliJ IDEA – Code reformat and rearrange shortcut keys - Websparrow
July 24, 2020 - In IntelliJ IDEA,we can use Ctrl + Alt + L to reformat and rearrange code in Windows and Linux machine and for Mac OS, use command + option + L.
🌐
Reddit
reddit.com › r/intellijidea › what are your most popular keyboard shortcuts in intellijidea?
r/IntelliJIDEA on Reddit: What are your most popular keyboard shortcuts in IntelliJIDEA?
January 4, 2021 -

I am using Windows 10, default keyboard shortcuts setting. The most frequently used keyboard shortcuts are as follows:

  • CTRL+D for duplicating current line;

  • CTRL+ALT+O for optimizing imports;

  • CTRL+ALT+L for formatting code;

  • CTRL+Y for deleting current line;

The following magics are also useful:

  • .var

  • .sout

  • .if

  • .for

  • .foreach

  • .null

  • .nn

Top answer
1 of 5
19
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.
2 of 5
15
Windows user here. All of those plus these: Ctrl + N / Ctrl + Shift + N: find class/type or file Ctrl + E: recent files Ctrl + Shift + A: action. My most frequently used action: move right to move/split a file to the other side Ctrl + Alt + Left/Right: navigate between locations I was at previously Ctrl + Shift + F12: close/collapse all tool windows, leaving only open files Ctrl + B: jump to definition Ctrl + Shift + I: quick definition view Ctrl + Shift + F: find within the open file/window Ctrl + W: expand selection Ctrl + Shift + W: shrink selection Alt + J: My most favorite and so fun to use. Multi selection of the same variable/words, then type and see the magic. Ctrl + D: git diffs F7: next diff while viewing diffs Ctrl + K: git commit
🌐
YouTube
youtube.com › shorts › DX5C19cmX9o
IntelliJ IDEA coding tips - reformat - YouTube
#intellijidea #intellij #java #jetbrains #programming #shorts
Published: November 24, 2023
🌐
Inspeerity
inspeerity.com › home › blog › know your ide: intellij idea. 7 keyboard shortcuts you didn’t know about (part 1)
Intellij IDEA keyboard shortcuts you didn't know about ★ Blog Inspeerity
May 13, 2024 - Instead of creating manually test classes you can use the shortcut Ctrl+Shift+T. Formatting and cleaning. If you have a problem with organisation of the code you can use Ctrl+Alt+L to format the code. If you want to organize the imports use Ctrl+Alt+O, to execute all the formatting features just use Ctrl+Shift+Alt+T. Also read: Know your IDE: IntelliJ IDEA (part 2) – Navigate Through the Project With Use of Keyboard.
🌐
JetBrains
jetbrains.com › help › idea › mastering-keyboard-shortcuts.html
IntelliJ IDEA keyboard shortcuts | IntelliJ IDEA Documentation
1 month ago - IntelliJ IDEA has keyboard shortcuts for most of its commands related to editing, navigation, refactoring, debugging, and other tasks. Memorizing these hotkeys can help you stay more productive by keeping your hands on the keyboard. All default shortcuts are configurable and you can also assign shortcuts to any action that does not have them by default. For the predefined keymaps, refer to Predefined macOS keymap and Predefined Windows keymap.
🌐
Marit van Dijk
maritvandijk.com › home › for the record: how to format records in intellij idea
For the record: How to format records in IntelliJ IDEA - Marit van Dijk
May 19, 2025 - Now if we have any code with a record (or any other simple class), we can use the Reformat the code (⌘⌥L on macOS) / Ctrl+Alt+L on Windows/Linux) to reformat the simple class accordingly. Note that you’ll need to use the shortcut twice to remove custom line breaks. The same formatting will be applied in other situations.
🌐
YouTube
youtube.com › intellij idea by jetbrains
Code Formatting in IntelliJ IDEA (2020) - YouTube
IntelliJ IDEA lets you reformat your code according to the requirements you've specified in the Code Style settings. In this screencast we're going to look a...
Published: May 20, 2020
Views: 14K
🌐
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 …