Get Vim Bindings In Xcode 9

John | March 19, 2018

Are you new to XCode and love the increase in productivity that vim bindings provide? Then you will be disappointed to find that Apple has neglected to include vim support in XCode. Now, you might be saying “well I’m sure there is a vim plugin for xcode,” but you would be wrong. In its infinite wisdom, Apple removed third party plugin support as of Xcode 8. Now don’t get too upset. Luckily, you can still install third party plugins by self-signing the code. In to get vim bindings in xcode, we will be signing and building XVim2.

Step One

First thing to do is to make sure you have Xcode closed.

Create a Certificate

  • From spotlight, search for Keychain Access and hit enter
  • Click Keychain Access from the system menu bar, select Certificate Assistant, and then Create a Certificate

  • Set the Name to “XcodeCert”, Identity Type as “Self Signed Root”, and Certificate Type as “Code Signing” then click create.

Sign The Code

Now that we have a certificate, we can now sign:

  • Open a terminal window and type: sudo codesign -f -s XcodeCert /Applications/XCode.app/
  • The codesign command is used to create, check, and display code signatures. Here the -s flag is used to specify the identity to sign the code with. In this case, it is our “XcodeCert”. The -f flag is short for force which means codesign will replace any existing signatures when signing.
  • Run this command and enter you password. Be prepared to wait because it takes approximately forever.
  • Once you get a prompt asking to allow codesign to use your cert, click “allow”.

Install Xvim2

With that out of the way, we’re free to install Xvim2:

  • Clone the XVim2 repo by running: git clone https://github.com/XVimProject/XVim2.git
  • cd into the XVim2 directory you just created
  • Verify that xcode is pointing to the correct developer directory for Xcode and BSD Tools by running: xcode-select -p
    • If you don’t see /Applications/Xcode.app/Contents/Developer run: xcode-select -s /Applications/Xcode.app/Contents/Developer to select the correct directory
  • Run make to build Xvim2

Finishing Up

Once the make finishes running, you are almost done:

  • create your .xvimrc in your root directory and you can just copy and paste your existing .vimrc into it.

That’s It!

Now you can fire xcode and, check it out, You have vim bindings now!

Sources:

Alot of this info was taken from the Xvim2 github readme and then also from a Twilio blog post on installing xvim on xcode8: https://www.twilio.com/blog/2017/06/adding-vim-keybindings-to-xcode-with-xvim.html

By: John