[Vimoutliner] otl to headline numbering conversion program?

Steve Litt slitt at troubleshooters.com
Fri Mar 30 09:07:08 EST 2007


On Friday 30 March 2007 09:41, Stefan Schmiedl wrote:
> Steve Litt (30.03. 09:31):
> > Has anyone written anything like that yet? If so, please let me know. I'm
> > gonna write the docs now, and when I'm finished, if nobody's written this
> > program already, I'll write it using Node.rb.
>
> I did ... not quite ... and waaaay back in 2004:
>
> -rw-r--r--  1 stefan users     658 2004-03-16 09:30 vo_numbers.vim
>
> As far as I can see, it only numbers a single level, as I am not a
> friend of too many numbers in headings. But using the prefix mechanism,
> you could generate nested numbers, too, I guess.
>
> The following is totally unsupported, don't even think of asking me why
> I did something the way I did. I haven't touched vimscript for years.
>
> function! Number() range
>   let l:prefix = input("Prefix: ")
>   let l:postfix = input("Postfix: ", " ")
>   let l:count = 1
>   let l:indent = indent(a:firstline)
>   let l:current = a:firstline
>   while l:current <= a:lastline
>     if indent(l:current) == l:indent
>       let l:line = getline(l:current)
>       let l:line_ = substitute(l:line, '^\(\t*\)\(.*\)$',
> '\1'.l:prefix.l:count.l:postfix.'\2', "") call setline(l:current, l:line_)
>       let l:count = l:count + 1
>     endif
>     let l:current = l:current + 1
>   endwhile
> endfunction
>
> function! Denumber()
>   silent! s/^\(\t*\)[0-9.]* \(.*\)/\1\2/
> endfunction
>
> map ,,n :call Number()
> map ,,N :call Denumber()
>
> Have fun,

I'll have lots of fun Stefan. I don't know Vim language :-) Into what file 
would I stick this function?

By the way, this is no longer urgent. I submitted my docs as a .otl file, 
after doing a ,,B to get rid of the colons. Hey, if they can't take a 
joke :-)

Thanks Stefan,

SteveT


More information about the VimOutliner mailing list