Вопрос

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?

Это было полезно?

Решение

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.)

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top