[Vimoutliner] otl to headline numbering conversion program?
Stefan Schmiedl
s at xss.de
Fri Mar 30 10:27:59 EST 2007
Steve Litt (30.03. 10:07):
> > 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()
> 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
it.
The function needs to be invoked via :range call Number(), e.g.
:%call Number() or :.,+30call Number(), it even accepts a visual range.
s.
More information about the VimOutliner
mailing list