On Sun, Nov 30, 2008 at 3:52 AM, anhnmncb wrote:
>
> As title, I want to make a function for foldtext like this:

Looks to me like your function is confused...

> function MY_TeX_BiBFoldText()

You get a List containing the text of all lines in the fold:

>  let line = getline(v:foldstart, v:foldend)

Then you find the offsets in that list of the matching lines:

>  let matchlinea = match(line, '^\s*author.*{.*}.*') + 1
>  let matchlinet = match(line, '^\s*title.*{.*}.*') + 1

Then you use those offsets as line numbers, instead of offsets into a
list.  Why are you using getline(match()+1) here, instead of
line[match()] ?

>  let matcha = substitute(getline(matchlinea), '^.*{\(.*\)}*.*$', '\1', 'g')
>  let matcht = substitute(getline(matchlinet), '^.*{\(.*\)}*.*$', '\1', 'g')

Seems to me that those lines should be:

let matchlinea = match(line, '^\s*author.*{.*}.*')
let matchlinet = match(line, '^\s*title.*{.*}.*')
let matcha = substitute(line[matchlinea], '^.*{\(.*\)}*.*$', '\1', 'g')
let matcht = substitute(line[matchlinet], '^.*{\(.*\)}*.*$', '\1', 'g')

>  let matched = "title: " . matcht . "   author: " . matcha
>  return v:folddashes . matched
> endfunction

Try that, see if it helps.

~Matt

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to