Jaguar
unread,Apr 22, 2009, 2:03:28 PM4/22/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vim_dev
I would like to be able to highlight folds based on the text displayed
in the fold line, instead of the "Folded" highlight.
Here's my use case:
I created a filetype called "outline". I have folding setup so that
all the lines at indent level "x" will be folded up with the line
above them at indent level "x-1". Like so:
setlocal foldmethod=expr
setlocal foldexpr=(getline(v:lnum)=~'^$')?-1:((indent(v:lnum)/4<indent
(v:lnum+1)/4)?('>'.(indent(v:lnum)/4+1)):indent(v:lnum)/4)
setlocal foldtext=(match(getline(v:foldstart)[0],'\\s')
==-1)?'»'.getline(v:foldstart):substitute(getline(v:foldstart),'\
\s','»','')
So, the following file...
Tasks:
Folding ~ done ~ implement folding for outline filetype
set foldmethod ~ done
set foldexpr ~ done
set foldtext ~ done
Highlighting ~ done ~ implement syntax highlighting for outline
filetype
Highlight based on indent ~ done
Highlight based on keyword ~ done
Fold highlight ~ open ~ Get folded lines to use the right
highlighting
Search docs for solution ~ done: failed
Search wiki for solution ~ done: failed
Search groups for solution ~ done: failed
Make new feature request ~ open
Awesomeness ~ todo ~ Vim bliss
...when folded with "zMzr" will look like this:
Tasks:
» Folding ~ done ~ implement folding for outline filetype
» Highlighting ~ done ~ implement syntax highlighting for outline
filetype
» Fold highlight ~ open ~ Get folded lines to use the right
highlighting
Awesomeness ~ todo ~ Vim bliss
This is all well and good. However, when unfolded, the keywords
"done", "open", and "todo", are highlighted differently. When folded,
the entire line is highlighted with the "Folded" highlight. With a
lot of lines with all the same highlighting, it's hard to pick out the
"done", "open", and "todo" keywords. So, what I want is for the
folded lines to be highlighted based on the foldtext, rather than the
"Folded" highlight.