On 07-23/20:32, Erik Christiansen wrote:
> 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.
In modelines you have to escape the colon (if your foldexpression is more
complicated than `getline(v:foldstart)` you should consider using its own
function for readability and extendability)
The best way is to give your files proper endings and to use filetype files
(`~/.vim/ftplugin/$filetype.vim`). If you use filetypes unkown to vim you have
to use a ftdetect file (`~/.vim/ftdetect/$filetype.vim`, more info[1] - it's
really just an augroup).
[1] http://learnvimscriptthehardway.stevelosh.com/chapters/44.html
--
Viktoriastrasse 22
76133 Karlsruhe
Nr.: 0721 / 96 55 63 95
Handy: 0178 / 53 17 067
/"\ ASCII Ribbon Campaign
\ / - against HTML emails
X - against proprietory attachments
/ \ http://en.wikipedia.org/wiki/ASCII_Ribbon_Campaign
--
--
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.
Thursday, July 23, 2015
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment