I've just contributed a program to the NoSQL project, and now need to document
it. I'll author the doc as an outline with lots of body text. What I'd like
to do is have a program convert something like this:
: A horse is a horse of course of course
: but noone can talk to a horse of course
The Need for Speed
: Users get nervous if an update
: takes more than 1/2 second, so
: updates must be fast.
1: Updmerge documentation ********
1.1: Philosophy ******
A horse is a horse of course of course but noone can talk
to a horse of course
1.1.1: The Need for Speed ****
Users get nervous if an update takes more than 1/2 second,
so updates must be fast.
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.
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
> let l:current = l:current + 1
> function! Denumber()
> silent! s/^\(\t*\)[0-9.]* \(.*\)/\1\2/
> 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
> I'll have lots of fun Stefan. I don't know Vim language :-) Into what file
> would I stick this function?
The vim stuff above (minus mail quoting characters) could be appended
to .vimoutlinerrc, so it will be available whenever outlines are
available. Or you save it to a file and :source the_file when you need
The function needs to be invoked via :range call Number(), e.g.
:%call Number() or :.,+30call Number(), it even accepts a visual range.