How to use Windows keymap on Mac and in your favorite IDE for example IntelliJ?

Why? An example would be working on a multi-platform system where one needs to deal with Linux, Windows, and Mac. Having a common hotkey mapping will remove the friction; get the edge on efficiency; reduce the learning curve and use more ergonomic tooling interfaces across platforms.

There are the following problems out of the box:

1. Mac hotkeys are different compared to Windows
1.1 Control (Win) aka. Command (Mac) is not on the bottom right edge.
1.2 There is a third key on mac. Ctrl, Alt vs Control, Option, Command

Indeed due to Win and Mac hotkey differences, the Mac Intellij keymap is as well different.

2. IDE such as IntelliJ Mac hotkey is very different
2.1 How to find Windows keymap in IntelliJ on Mac?
2.2 How to solve the problem with the Karabiner elements?
2.3 Conflicting keymaps with Mac internal shortcuts

1.1 Changing keymapping in on Mac

On the Mac be default thump copy-paste is used so: Command + c. etc.

Easy! Just change the mapping from Mac Preferences. Could vary across the versions but for v11+ would work as follows.

System Preferences ->
Keyboard (tab) ->
Modifier Keys ->
Select keyboard

Whoila! You got your pinky copy instead of a thump copy. Something You would use out of the box on the Win and Linux systems.

1.2 On the Mac there is one more modifier key.

2.1 How to find a Windows keymapping in Intellij?

Obviously, IntelliJ provides several choices. But one would not be able to find a keymap that provides the same Windows keymap experience.

One could find the XWin keymap under the plugin marketplace search.

Problem with IntelliJ’s XWin keymap on Mac

2.1.a The familiar Ctrl key is not on the most right bottom corner as We have swapped copy-paste in the Mac to have a pinky copy paste.

We can fix with replacing control with meta in XWin keymap
https://gist.github.com/vikreinok/69e18a79d08db956db4b56a9ae2feb91

Now, where we can find the keymap config file in Mac?

How to change the file manually:
First, we use a local repository to store the settings.
File → Manage IDE Settings → Settings repository

When you will copy the XWin keymap, you will give it your name. XWin copy for example. Where are you able to find this custom copy?
/Users/username/Library/Application Support/JetBrains/IntelliJIdea2021.1/settingsRepository/repository/keymaps

2.1.b The Familiar Alt key is not leftmost to the Space key.

2.2 Alt + any other key produces as a symbol.

2.2.a To counter that we need to install Karabiner elements

https://karabiner-elements.pqrs.org/docs/getting-started/installation/

2.2.b Edit a rule file [2]
/Users/username/.config/karabiner/karabiner.json and added your own rule in that JSON under:
profiles > complex_modifications > rules:

{
"description": "ctrl/command swap",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "left_control"
},
"to": [
{
"key_code": "left_command"
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "left_command"
},
"to": [
{
"key_code": "left_control"
}
],
"type": "basic"
}
]
}

2.3 Conflicting keymaps with Mac and how to fix them

  • Spotlight search (command+space)
    Preferences ->Keyboard -> Shortcuts -> Spotlight. ( remat to option + space for example)
  • Hide window (command + space)
    Control + h ( shows hierarhy in IDEA)
  • Quit program (control + q)
    In IDEA it is showing

Summary

References:

  1. https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf
  2. https://gist.github.com/vikreinok/69e18a79d08db956db4b56a9ae2feb91

Software developer