Wednesday, December 23, 2015

Matlab Comments in Vim

I'm using vim-commentary but having problems with matlab and octave scripts trying to comment like c blocks

in the vim-commentary documentation it says to do:
autocmd FileType matlab setlocal commentstring=%\%s

but it wasn't working for me.  The solution was to open the matlab.vim file as admin

sudo gedit /usr/share/vim/vim74/ftplugin/matlab.vim

and add

setlocal commentstring=%\%s

to the file

Now it works automatically when vim loads a matlab file!

No comments: