Top => IntelliJ IDEA on Mac OS X
The extract constant refactoring converts a local variable into an instance variable.
- ⌃⇥ (Ctrl + Tab) - navigate from the project view pane to an editor pane
- ⌘↖︎ (Command + Home) or fn⌘← (Fn + Command + Left Arrow) or fn↑ (Fn + Up Arrow) - navigate to the top of the file (in editor)
- ⌥→ (Option + Right Arrow) - move forward by token while selecting
- ⌥⇧→ (Option + Shift + Right Arrow) - move forward by token
- ⌘L (Command + L) - go to line number
- ⌘F (Command + F) - find in file
- ⌘G (Command + G) - repeat the last find operation
- ⎋ (Escape) - dismiss "find" dialog
- ⌘⌥C (Command + Option + C) - open the "extract constant" dialog
- ⏎ (Return/Enter) - complete action
Keystrokes without explanations
⌃⇥
⌘↖︎ (or fn⌘←)
⌘L
11
⏎
hold ⌥
→
→
release ⌥
hold ⇧⌥
→
release ⇧⌥
⌘⌥F
⏎
↓
Walkthrough of steps with explanations
- Open the Java source file, LongConditional.java.
- If focus is not already in the editor pane for LongConditional.java, press ⌃⇥ (Ctrl + Tab) and select the editor pane for LongConditional.java.
- Press ⌘↖︎ (Command + Home) or fn⌘← (Fn + Command + Left Arrow) or fn↑ (Fn + Up Arrow) to navigate to the top of the file (depends on the keyboard).
- Press ⌘L (Command + L) to open the "go to line number" dialog.
- Enter line number 11.
- Press ⏎ (Return/Enter) to move the caret to the specified line number.
- Hold ⌥ (Option) and press → (Right Arrow) twice to advance to the token, errorCount.
- Hold ⇧⌥ (Shift + Option) and press → (Right Arrow) once to select the token, errorCount.
- Press ⌘⌥F (Command + Option + F) to open the "extract field" dialog.
- Press ⏎ (Return/Enter) to accept the defaults and complete the refactoring.
- Press ↓ (Down Arrow) and the caret should land on the token, result, on the line below.
- Press ⌘⌥F (Command + Option + F) to open the "extract field" dialog.
- Press ⏎ (Return/Enter) to accept the defaults and complete the refactoring.
To reverse the changes:
- Press ⌘Z (Command + Z) repeatedly until the changes have been reversed. Should be 30 times.