Вопрос

I am having problem with Vim folding when using laravel blade template engine. It is displaying folding markers on the page. So after refreshing browser window I see /{{{/

My folding is set to marker - it is the only folding setting in my .vimrc.

Anyone knows how to fix that ? Thanks.

Ok here is update:

After entering verbose commands in vim here is what I got:

:verbose set fdm → foldmethod=marker
:verbose set frm? → foldmarker = {{{,}}}
:verbose set fdt? → foldtext=foldtext()

I am thinking since blade is based on regex, it can't filter properly foldmarkers ?

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

Решение

The idea behind foldmarkers is that they are contained in the source code file, but otherwise neutral with regards to the programming language. This usually means that they have to be contained inside comments. If you still see them in the browser, that means that you failed to hide them from the template engine.

You need to embed them inside comments, e.g. HTML ones: <!-- {{{1 -->. Vim can help you with this (on zf - create fold) through the 'commentstring' option.

Note that foldmarkers are mostly only used for personal, custom text files (where you want to create a folding structure without having a proper syntax or other formal structure). For programming languages, you rather use either syntax, expr, or indent foldmethods. This is both easier than managing folds yourself, and it doesn't litter the code with editor-specific rubbish that doesn't belong there (or do your non-Vim-using colleagues like this?!)

In case your template engine is based on HTML, this (when put into ~/.vim/after/syntax/html.vim, together with :setlocal foldmethod=syntax should give you some folding:

:syntax region htmlFold start="<\z(p\|h\d\|table\|colgroup\|thead\|tfoot\|tbody\|t[dhr]\|pre\|[diou]l\|li\|span\|div\|head\|script\|style\|blockquote\|form\)\%(\_s*\_[^/]\?>\|\_s\_[^>]*\_[^>/]>\)" end="</\z1\_s*>" fold transparent keepend extend containedin=htmlHead,htmlH\d
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top