On May 13, 1:04 am, Jan Larres <[email protected]> wrote:
> Hi all,
>
> I've recently been trying to write a 'foldtext' setting that is specific
> to LaTeX and would include useful information like for a example the
> caption information for a folded environment. But then I discovered that
> the 'foldtext' setting is local to a window and not to a buffer, making
> filetype-specific foldtexts pretty much impossible. So if I were to for
> example edit my LaTeX file and a C file that I'm writing about in the
> same window I can't have foldtexts that are tuned for those files,
> respectively.
>
> Is there a reason for this? Would it be possible to change it? I can see
> the rationaly for having some fold settings window-local so you can have
> for example the file folded in one window and unfolded in a different
> one, but I can't see any reason why the foldtext should behave in the
> same way.
>
> I guess you could sort of work around that by defining buffer-local
> functions, but it probably wouldn't be pretty.
>

A better workaround, if you need it after the other suggestions, is to
test the filetype inside the function you define for your foldtext
expression. This way you can set the same foldtext just once, in
your .vimrc, and it will act differently depending on the filetype in
the window in which it is executed. This is *basically* how my own
foldtext works.

Actually, mine switches between 3 or 4 different possible methods of
foldexpr, based on a buffer-local variable, and I use ftplugins to set
this buffer-local variable. This allows my foldtext function to check
for a single value of this variable instead of several values of
&filetype. But, using &filetype directly would have been the more
straightforward way.

My foldtext also checks for fdm=diff to set a more sensible text for
diff mode.

-- 
You received this message from the "vim_dev" 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

Raspunde prin e-mail lui