Import IntelliJ key bindings to Xcode
Asked Answered
C

2

44

Is there a keymap for Xcode that would make it behave the same as products from JetBrains? (IntelliJ keymap)

I tried Googling, but Google is completely useless in this case, as it presents results for the other way around (importing Xcode key map to IntelliJ products), when searching for "import intellij key bindings into xcode".

I'd prefer not to see myself reassigning all the bindings manually :)

Chairwoman answered 18/8, 2017 at 12:5 Comment(5)
Did you ever find a solution to your question? I would be interested as well :)Franconia
@Franconia Unfortunately not.Chairwoman
looks for a solution as wellInordinate
Did you ever find a solution to your question? I would be interested as wellRovner
@HonzaKalfus I just added below an answer with a link to a repository where I started migrating part of intelliJ keybindings to an xCode profile. Feel free to collaborate and give it a look!Cerebrum
C
6

I just created a repository with part of IntelliJ bindings migrated to an xCode template(including the custom duplicate line). Feel free to give it a look, try it and keep improving it. Sadly the only way we can achieve this is doing it manually.

https://github.com/FrangSierra/Xcode-IntelliJ-Keybinds

There is also another repository with the color theme of dark IntelliJ in case any of you could find it interesting!

https://github.com/FrangSierra/Xcode-IntelliJ-Dark-Color-Theme

Cerebrum answered 3/7, 2020 at 10:50 Comment(0)
B
4

TL;DR: This doesn't seem possible with the way both editors handle their keybindings.


I tested this using AppCode 2019.2 and Xcode 10. I first tried to find where the two IDEs keep their keymap files on disk.


Xcode keeps its keymap files in ⁨Library⁩ ▸ ⁨Developer⁩ ▸ ⁨Xcode⁩ ▸ ⁨UserData⁩ ▸ ⁨KeyBindings⁩ and as a .idekeybindings file. Opening it up in TextEdit revealed it's a plist-formatted file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

I was a little surprised to find it empty, but decided to try and manually trigger an update by setting a custom keybinding. Opening the file again reveals that Xcode only stores the diff of keybindings:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Menu Key Bindings</key>
    <dict>
        <key>Key Bindings</key>
        <array>
            <dict>
                <key>Action</key>
                <string>orderFrontAboutPanel:</string>
                <key>Alternate</key>
                <string>NO</string>
                <key>CommandID</key>
                <string>Xcode.IDEKit.CmdDefinition.AboutXcode</string>
                <key>Group</key>
                <string>Xcode Menu</string>
                <key>GroupID</key>
                <string>Xcode.IDEKit.MenuDefinition.Main</string>
                <key>GroupedAlternate</key>
                <string>NO</string>
                <key>Keyboard Shortcut</key>
                <string>~`</string>
                <key>Navigation</key>
                <string>NO</string>
                <key>Title</key>
                <string>About Xcode</string>
            </dict>
        </array>
        <key>Version</key>
        <integer>3</integer>
    </dict>
</dict>
</plist>

So, theoretically, if we just got the keybindings from Intellij, and formatted them to be like the Xcode ones, it should be no problem


Then we turn to the Intellij platform. Luckily, I didn't have to do much hunting for these key files, because Intellij already documented them.

Keymaps for Intellij are located under ~/Library/Preferences/IntelliJIdea2019.2/keymaps. In my case (using AppCode), it was under ~/Library/Preferences/AppCode2019.2/jba_config/mac.keymaps/ To my surprise, it was also empty. Trying to set a manual keybind resulted in similar behavior to what I saw in Xcode:

<keymap version="1" name="Default for macOS copy" parent="Mac OS X 10.5+">
   <action id="EditorBackwardParagraph">
     <keyboard-shortcut first-keystroke="shift ctrl meta alt back_quote" />
   </action>
</keymap>

Unfortunately this was also confirmed by the same doc as linked above, which states:

Each keymap file contains only the differences relative to the parent keymap.


So, unless you have every single keybinding as custom, there is currently no way to export keybindings from one to another. Sure, you can do it manually, but as you said that's counterproductive.

Bo answered 31/7, 2019 at 22:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.