Monday, August 1, 2011

Re: A mile of dashes added to foldtext

On Mon, 1 Aug 2011, Erik Christiansen wrote:

> set foldtext=substitute(getline(v:foldstart),'/\\*\\\|\\*/\\\|{{{\\d\\=','','g')
> [}}}]
>
> [...]
>
> let sub = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
> [}}}]
>
> [...]
>
> It has also become clear that I'll have to constrain the folding with
> some "au BufNewFile,BufRead", because .vimrc is only partly displayed,
> apparently due to the foldtext regex being interpreted as the start of
> a fold.

Three ways to work around this portion of the problem:

1. Limit the damage by placing a closing foldmarker in a comment:

e.g.

set foldtext=substitute(getline(v:foldstart),'/\\*\\\|\\*/\\\|{{{\\d\\=','','g') " }}}


2. Replace the three-open-brace portion of the regular expression with
something equivalent:

e.g.:

Change '{{{' into '[{]{{' " [ed. preventing the fold on this line]: }}}


3. Use setlocal instead of set to set up foldmethod=marker.

If you set fdm=manual, then folding is manual globally. Then in
specific filetypes you can enable fdm=marker.

E.g. I use:

" in .vimrc:
set fdm=manual
au Filetype php setl fdm=marker

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment