Friday, May 7, 2010

MacVim and Xcode, and what I am using that is pretty sweet



Hi all, I have been using Xcode and MacVim to get work done. MacVim has some great plugs that really integrate well with Xcode. The set of plugins that I am using are cocoa.vim, snipMate.vim, objc_matchbracket.vim, and comments.vim. Rock on VIM!!!

However, there is one really annoying cocoa.vim issue with all of this and that is that the documentation feature "K" or :CocoaDoc does not load right if you are using Firefox and have it set as your default browser.




So what is the fix you may ask, well its not changing your default browser. The solution is a bit of a hack but it involves editing a line in the cocoa.vim script. The result of doing this hack will be that all of your documentation look-up request done within MacVim will open in Safari, awesome a dedicated use for Safari.

If you like the sound of having Safari be the documentation viewer, then after installing cocoa.vim edit the file located at:
~/.vim/autoload/objc/man.vim

In that file Find:
call system('osascript -e ''open location "file://'.a:file.'"'' &')

Replace it with:
call system('osascript -e ''tell application "Safari"'' -e ''open location"file://'.a:file.'"'' -e ''activate'' -e ''end tell'' &')

(NOTE: if you copy and paste the above be sure to remove any return lines in it, that whole thing should be just one long line as pictured below)