[Vimoutliner] otl to headline numbering conversion program?
Stefan Schmiedl
s at xss.de
Fri Mar 30 08:41:45 EST 2007
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,
s.
--
Stefan Schmiedl
+-------------------------------+----------------------------------------+
|Approximity GmbH | EDV-Beratung Schmiedl |
|http://www.approximity.com | Am Bräuweiher 4, 93499 Zandt, Germany |
|mailto:stefan at approximity.com | Tel. (09944) 3068-98, Fax -97 |
+-------------------------------+----------------------------------------+
More information about the VimOutliner
mailing list