开发者

Foldmethod=marker and syntax at the same time?

Is it possible for a same file to use folding based on both markers and s开发者_如何学编程yntax ?


Since foldmethod can only be set to one at a time, I think the only way you could really do this would be to use :set foldmethod=expr and hack about with foldexpr, and even then I'm not sure it would be able to do exactly what you want.

So, short answer: no

Long answer: maybe, muck about with foldexpr if you dare to see if you can get the desired results


Maybe you can emulate your markers by additional syntax rules?

But hard to tell without more input.


The AutoFold.vim plugin attempts to address this: http://www.vim.org/scripts/script.php?script_id=925

As an alternative, I thought I'd have a little go myself, by introducing a new syntax rule for markers. Unfortunately this needs to be declared before any syntax rules for comments, or the comment rule will mask our marker rule.

So here is what I tried to insert my rule early:

:syn clear

:syn region myMarkerFold matchgroup=myDummyGroup start="{{{" end ="}}}" transparent fold

:exec "runtime! syntax/" . &filetype . ".vim"    

It didn't quite work. The last line immediately cleared my custom rule. Drop the last line, and folding works, but of course none of the language will be syntax-matched or highlighted! (By the way, I was testing this on a .vim file.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜