Last Updated: February 25, 2016
· cmdel

Run a Matlab script from ViM

Add the following to your ~/.vimrc file and you'll have the option of running a script from within your editor of choice; ViM!
This tries to mimic the actual use of the F5 key in Matlab Desktop, so feel free to change it something more handly. My choice is < leader >r, where the < leader > is the ','.

map <leader>r :w<CR>:!/Applications/ -nodesktop -nosplash -r "try, run %:p, pause, catch, end, quit" <CR> <CR>

You would probably need to change the

< / >

part to what your version of Matlab is. I should say that this should also work in Linux by simply changing the path, but I haven't tried it.