Brendan Dawes

Analogue + Digital


Goodbye XCode, Hello Vim and OpenFrameworks

Since moving to Vim over a year ago for all my coding, using another code editor is always a chore. Such is the case using Xcode when working on OpenFrameworks projects. Luckily I can use Vim to work on OF projects after reading this great post from the OF forum about setting up Vim and OF.

Yet in that post there was one piece of the puzzle missing. To trigger compiling the code with the make command you would normally have to be in the same directory as the Makefile, which OF conveniently makes when you first setup an OF project. The problem is all the code you work on resides one level down in the src directory. Running make from there will do nothing. Thankfully it can be rectified by adding this line to your .vimrc:

set makeprg=[[\ -f\ Makefile\ ]]\ &&\ make\ \\\|\\\|\ make\ \RunRelease\ -C\ ..

When you issue the :make command it will check to see if the Makefile is present in the current working directory and if not will go up a directory and look for it there. I've also appended RunRelease which instead of just compiling the code will also run the newly made binary as well.

This works especially well in Macvim as you can simply press CMD-B to build and run your project.

Syntax Highlighting

You can add correct syntax highlighting for OpenFrameworks c++ files using this plugin.

Now when working on OF projects I can stay in Vim without having to use Xcode.