I’m glad that I know how to use most of IntelliJ with the keyboard.
Using the mouse is slow and also puts a lot of strain on my wrist.
But I noticed that I’m using the mouse for some tasks. That’s usually because I don’t know
how to use the keyboard for it.
I was wondering for a long time how to use the merge dialog without the mouse.
I was always thinking “This has to be possible! Somehow…” but was too lazy (or stubborn) to
find out how to get of the mouse here.
Our Use Case
Could you use these dialogs without your mouse?
List of Conflicts
For this dialog, I usually do one of these tasks:
- Resize the columns and/or the window to see all of the paths and the names of the branches
I have never used
Group files by directory yet—I can’t remember that this already was in older versions.
And you couldn’t use it with your keyboard, anyway. There’s no mnemonic defined for it and thus no
shortcut to enable it using the keyboard.
Merging conflicts in IntelliJ
I already knew about these shortcuts:
- F7 to navigate to the next conflict
- Shift + F7 to navigate to the previous conflict
But I always use the mouse for these tasks:
- put focus on the left, middle, or right pane by clicking into it
- accept the item on the left or the right, i.e. click on the little arrows pointing towards the center
- reject an item on the left or the right, i.e. click on the little
- change the selection in the
- change the type of highlighting, e.g. to use
Finding the shortcuts
It’s not very intuitive to find out about the keyboard shortcuts. The tooltips for the actions above
are not showing the shortcuts.
Head over to the settings at File > Settings… > Keymap. Now enter
diff in the filter input on the right.
Have you already spotted the entry for Accept Left Side and Accept Right Side?
I was very happy to see that it’s possible to use the keyboard for these actions.
Oh, and there’s
Select Opposite Diff Pane. Isn’t that helpful?
And, if you look closely at the list, you’ll see unassigned shortcuts for
Append Left/Right Side and
Ignore Left/Right Side.
I tested this a bit. Working in the middle column, navigating with
, accepting left or right with
Alt + Shift + Left or Alt + Shift + Right and finally accepting the modifications with Alt + Enter
seems good enough to me.
Hopefully, you’ve learned something new. At least I did. It’s good to use the mouse less and be able to work
a bit faster with the diff and merge tool.
I added an overview with the most common shortcuts I’m (now) using with Diff & Merge.
Shortcuts for IntelliJ’s list of conflicts
I’ll make more use of these helpful shortcuts:
|Task||macOS||Linux / Windows|
|Resize the window to get wider columns||Ctrl + Shift||Ctrl + Shift|
|Accept Yours||Alt + Y||Alt + Y|
|Accept Theirs||Alt + T||Alt + T|
|Merge||Alt + M||Alt + M|
Shortcuts for IntelliJ’s merge window
|Task||macOS||Linux / Windows|
|Put focus into middle column||Ctrl + Tab||Ctrl + Tab|
|Accept change on the left||Ctrl + Shift + Left||Alt + Shift + Left|
|Previous change||Shift + F7||Shift + F7|
|Apply||Option + Enter||Alt + Enter|