[Vim-latex-devel] label viewing
Brought to you by:
srinathava,
tmaas
From: Mikolaj M. <mi...@wp...> - 2003-01-15 23:13:49
|
Hello, I began to write function to view label names and have problems... It works in this way: write \ref{ press <F9> you should see lines with \label ;choose number and nothing. If you wrote \ref{i you will see only list of labels which began on i. ---------------------- " For making labels " inoremap <F9> <C-o>:call Labtest()<cr> function! Labtest() let pos = line('.').' | normal! '.virtcol('.').'|' let g:curline = strpart(getline('.'), col('.') - 10) let g:prefix = matchstr(g:curline, '{\zs.\{-}$') redir @a exe 'silent g/\\label{'.g:prefix.'/p' redir END let g:lob = @a let g:lob = substitute(g:lob, "\n", '', '') " here is first problem: I'd like to present whole lines with \label tag " to give some context (also it would take some time to process each " line to get only \label tag)[1] but Tex_CreatePromt and Tex_Strntok have " something against chars like \n or ¤, with , these functions don't " have problems, but if I want to give whole lines , as separator can " cause problems let g:lob = substitute(g:lob, "\n", '¤', 'g') let g:common_label_prompt = Tex_CreatePrompt(g:lob, 1, '¤') . \ 'Enter number of label: ' let g:inp = input('Enter number of label:'."\n".g:common_label_prompt) if g:inp == '' exe pos return 0 endif let g:labelline = Tex_Strntok(g:lob, '¤', g:inp) let g:labelname = matchstr(g:labelline, '\\label{\zs.\{-}\ze}') exe pos " As usual I have problems with simple things :(. How put " g:labelname.'}' after \ref{, \pageref{ or similar. endfunction --------------------- [1] When two \label are in one line can be easily solved with if g:lob =~ "¤.\{-}\\label{[^¤]\{-}\\label{.\{-}¤" let g:glob = substitute(g:glob, "\(¤.\{-}\\label{.\{-}}\)\([^¤]\{-}\\label{.\{-}¤\)", "\1¤ cont -> \2", 'g') endif OK, I didn't test it but problem is possible to solve and IMO faster then iterate through whole g:glob to get only \label{..} things. Mikolaj |