2

I've just recently started to use the folding functionality of vim and it's very helpful for the languages that it works really well for.

My issue lies in the way vim comments out the fold markers in scilab code. It defaults to

/*{{{*/ and /*}}}*/

which works great in languages like C, but is not actually a comment in scilab. I get a multiplication error when i try to run the code.

I've tried adding

autocmd FileType scilab set fmr=//{{{,//}}}

to my .vimrc file which doesn't quite do what I'd like. It results in

/*//{{{*/ and /*//}}}*/

which are still not comments. The code "folds" fine but becomes unusable. I could set up a macro to replace every instance of "/*" with "//", but that could have unintended consequences when applied globally to a file.

So the question is: how can i setup vim fold markers comments for scilab files such that it will not render the file unusable?

Shimon Rachlenko
  • 5,469
  • 40
  • 51
aepksbuck
  • 367
  • 2
  • 10

2 Answers2

3

You do not add the comments to 'foldmarker' itself, there's the 'commentstring' option that influences how Vim surrounds the fold markers (when creating folds with zf). Try setting

:setlocal commentstring=//%s

for your scilab filetype. (Put the command in ~/.vim/after/ftplugin/scilab.vim to make it permanent.)

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
1

It sounds to me like vim doesn't understand how SciLab comments work. I'm not sure if vim comes with SciLab syntax logic these days, is syntax highlighted correctly in your SciLab files? If not, you can get the syntax file from here.

Is there a particular reason you want to use marks? They aren't actually needed. If you don't want vim to auto-fold by syntax or indentation level, you can still manually define folds with

:set foldmethod=manual

That lets you select a chunk of text in visual mode and make it into a fold with 'zf'. No marks required.

More info on various vim folding techniques here.

Alex Hammel
  • 345
  • 1
  • 8
  • I've played with manual folding and don't like having to set views to be loaded when the file is open. I use indentation in my code to make it human readable, but don't necessarily want to fold everything that's indented. Using marks seems to be the easiest way for me to transfer the folds that I've made from my computer at work to my computer at home. I don't know if manual folds will still work the same way. – aepksbuck Feb 15 '13 at 22:22
  • Scilab comments in the 5 familly are just // Version 6 will have /* */ as many other languages but it is not for today. – Sylvestre Feb 16 '13 at 10:27