> When I open latex files I would like to be able to fold with one vim
> expression on the top of the file from \htitle to \clearpage.
>
> I have a lot of blocks like this:
> \htitle{Latex Title}
> bla bla bla
> bla bla bla
> \clearpage
>
> And I would like to get this
> + Latex Title
>
Really, this is only very little tested, but seems to work so far:
fu! FoldTeXLines(lnum)
if !exists("s:fold")
let s:fold = 0
endif
let line = getline(a:lnum)
if line =~ '^\s*\\htitle'
let s:fold = 1
return s:fold
elseif line =~ '^\s*\\clearpage'
let s:fold = 0
return 1
endif
return s:fold
endfu
fu! FoldText(line)
return '+ '. matchstr(getline(a:line),'^\s*\\htitle{\zs.*\ze}')
endfu
setl fdm=expr fde=FoldTeXLines(v:lnum) fdt=FoldText(v:foldstart)
regards,
Christian
--
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