Thursday, July 23, 2015

Only some foldmethods can be set in modelines?

Let's take the simplest case. For each exception to my general case of
fdm = marker, I have begun to include in .vimrc e.g.:

au BufNewFile,BufRead ~/Embedded/dev_data/my_list call SimpleFold()

and one:

" Fold text blocks separated by EMPTY lines, so
" a line with whitespace unites two blocks.
function SimpleFold()
setlocal foldexpr=getline(v:lnum)=~'^$'&&getline(v:lnum+1)=~'\\S'?'<1':1
setlocal foldtext=getline(v:foldstart)
setlocal foldmethod=expr
endfunction

But that costs the labour, clutter, and maintenance nightmare of adding
a file-specific line for each file with a non-default foldmethod.

BUT, if I instead append the three lines of SimpleFold() as modelines in
the target file, then there are errors: lnum and foldstart are unknown
to Vim in modelines, at least in:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 2 2015 20:12:09)
Included patches: 1-688

(OK, I'm on debian, so it's old. )

What I _could_ do is make the above the default fdm, and add the
following modeline to all the currently defaulted files:

vim: foldmethod=marker foldmarker={{{,}}} foldopen-=block commentstring=

That seems to work. All the previously defaulted files would come out of
the woodwork over time.

OTOH, is there a better way to do this, I can't help wondering?

Erik
(Pausing to put another log on the fire. It's midwinter down under.)

--
In Bavaria, there are over 700 small biomass plants dotted around the country.
- http://www.abc.net.au/news/2015-07-19/tasmanian-forest-industry-fired-up-about-biomass/6628822
(Hmmm ... that recognition might be quite popular south of the Weißwurstäquator.)

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment