Home·Keyboard shortcuts

IntelliJ IDEA · Extract a method

Refactoring

Windows · Linux

Ctrl+Alt+M

Mac

Cmd+Option+M

Lifts the selection into a method and leaves a call in its place. It also hunts for identical fragments elsewhere and offers to replace those as well, so code far from the caret can change with it.

Group
Refactoring
Keys held
3

IntelliJ IDEA ships a different default keymap per platform, and two of them on macOS — "macOS" and "macOS System Shortcuts" — so when nothing works, look at Keymap in Settings first; whichever you pick then serves PyCharm, WebStorm, GoLand and Android Studio unchanged.

Reading the key names

  • Keys joined by + are pressed together: Ctrl+Shift+P means hold Ctrl and Shift, then P.
  • On a Mac, Cmd is ⌘, Option is ⌥ (labelled Alt on some keyboards), Control is ⌃ and Shift is ⇧.
  • Windows Ctrl usually becomes Cmd on a Mac, but not always — this reference lists both combinations separately.
  • With a Korean, Japanese or Chinese input method active, shortcuts built on letter keys may not fire. Switch to Latin input and try again.
  • When a combination does nothing, another program has often claimed it as a global shortcut first.

Common questions

Q. What is the shortcut for Extract a method in IntelliJ IDEA?

Lifts the selection into a method and leaves a call in its place. It also hunts for identical fragments elsewhere and offers to replace those as well, so code far from the caret can change with it. It is Ctrl+Alt+M on Windows and Cmd+Option+M on a Mac.

Q. Is it the same on Windows and Mac?

No — Ctrl+Alt+M on Windows, Cmd+Option+M on a Mac.

Q. How many keys is that?

3 pressed together. The combination sits under Refactoring in IntelliJ IDEA.

Shortcuts nearby