Try vim (even in Xcode!)

Try vim (even in Xcode!)

Summary

A co-worker told me a while back that I should learn vim or emacs. When asked why, he noted that learning one of them would not only help me edit text files faster, which means editing code faster, but learning one would help me become a more adaptable developer by reducing my reliance on IDEs. He suggested that I start writing notes using one of them to get started and to see what I thought. I chose to try out vim, and although I still write my notes like he suggested, vim has turned into one of my most useful and rewarding tools (I am sure emacs would have provided me with similar benefits). Some reasons why:


Tips for getting started with vim

How to get vim keybindings in Xcode

Step A: Re-sign Xcode

If you have done this before, you can skip down to #7.

  1. Close Xcode.
  2. Open Keychain Access and select login in the left pane.

    keychain_login

  3. From the top menu, select: Keychain Access -> Certificate Assistant -> Create a Certificate....

    keychain_create_certificate

  4. Change name to XcodeSigner.
  5. Change Certificate Type to Code Signing.

    create_certificate

  6. Press Create.
  7. Assuming Xcode is in your Application folder, run this in terminal to re-sign Xcode:
    • sudo codesign -f -s XcodeSigner /Applications/Xcode.app
  8. Be patient as the code signing will take some time.

Step B: Integrate vim into Xcode

  1. Either:
    • git clone https://github.com/XVimProject/XVim2.git or
    • If you have XVim2 cloned already, cd to the XVim2 repo and git pull.
  2. Confirm xcode-select points to your Xcode by running xcode-select -p.
    • You should see this output: /Applications/Xcode.app/Contents/Developer.
    • If this doesn’t show your Xcode application path, use xcode-select -s to set it.
  3. If you haven’t already, cd to the XVim2 folder.
  4. Run make in your terminal.
  5. Optional: Create a xvimrc to customize vim in Xcode -> ~/.xvimrc.
    • One thing to note is that some things are a little difficult to get working such as vim syntax highlighting since you are in the context of Xcode.
  6. Launch Xcode.
  7. When Xcode detects that there is an unexpected bundle XVim2.xcplugin, you want to Load Bundle.

    unexpected_plugin

  8. Xcode will then ask you for keychain access, which you need to give it.
    • Be patient with the number of times Xcode prompts you for keychain access. This is just a quirk about Xcode.

    keychain_access

  9. Note: If you accidentally press Skip Bundle or deny keychain access, close Xcode and enter this into terminal:
    • defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-X.X.
      • Where X.X is your Xcode version.

More advanced tip


Feel free to reach out on Twitter — cheers!

rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora