I tried many times to replace the default editor of Matlab with vim, but there are too many things, that are simply great about the Matlab IDE, namely

The one feature of vim I miss the most, in almost any editor, is search / replace using regular expressions (well, that and navigating with h-j-k-l).

For these reasons, I wrote a little script, which will open the current document – at the current line – in either MacVim or GVim, depending on which OS I am running. Of course you need to have MacVim or GVim installed on your system for this to work. On a Mac, you also need to put the shell script mvim, which comes with the installer of MacVim, in YOUR_HOME/bin/mvim, as described in the MacVim FAQ.

Now save the script below as open_in_vim.m in a directory, which is included in your Matlab’s path variable. Any time you want to open the current document in Vim, simply type open_in_vim in the command window. To make this new functionality more accessible, you can create a shortcut in Matlab’s toolbar.