vimL errors, inconsistent result, etc

34 views
Skip to first unread message

ping

unread,
Aug 27, 2012, 5:37:50 PM8/27/12
to vim-use Mailingliste
I have a function (poorly implemented, I'm learning ...):

714 command! Log2Asciidoc :call Log2Asciidoc()<CR>

715 function! Log2Asciidoc()

716 "remove some special CH, like ^M

717 :%s#\r\|\s\=\(^G\|^M\)##

718 "turn ^H into delete

719 :g/^H/while getline('.') =~ '[^^H]^H' | s/[^^H]^H//g | endwhile

720 "add asciidoc markup == and <<top>> for every command

721 :%s/^\(\S\S\+.\{0,40}\S#\s*[^:^H^G]\+\|slot
\d\d\=->\S\+.*\|->.*\|\*-\*-\*-\*-\*-\)$/\r== \1\r\r<<top>>\r\r/
722 ":set foldmethod=expr


723 "skip the 1st comand

724 :execute "normal! gg" . '/^\(\S\S\+.\{0,40}\S#\s*[^:]\+\|slot
\d\d\=->\S\+.*\|->.*\|\*-\*-\*-\*-\*-\)' . "\<cr>" ."j"
725 "indent between <<top>> and next command

726 :g/<<top>>/+1,/^== \(\S\S\+.\{0,40}\S#\s*[^:^H^G]\+\|slot
\d\d\=->\S\+\|->.\+\|\*-\*-\*-\*-\*-\)/-1 >
727 "add ---- below <<top>>

728 :%s@\(<<top>>\)@\1\r----\r@

729 "skip first command

730 :execute "normal! gg" .
'/^\(\S\S\+.\{0,40}\S#\s*[^:^H^G]\+\|slot
\d\d\=->\S\+.*\|->.*\|\*-\*-\*-\*-\*-\)' . "\<cr>" ."j"
731 "start from 2nd command, add ---- before command

732 :.,$s@^\(\S\S\+.\{0,40}\S#\s*[^:^H^G]\+\|slot
\d\d\=->\S\+.*\|->.*\|\*-\*-\*-\*-\*-\)$@\r----\r\1\r@
733 "add one more last asciidoc delimitor to end of file

734 :execute "normal! Go----" . "\<cr>\<esc>"

735

736 endfunc


I got errors:

<snipped a lot>
......
25 lines >ed 1 time
Error detected while processing function Log2Asciidoc:
line 11:
E385: search hit BOTTOM without match for: ^==
\(\S\S\+.\{0,40}\S#\s*[^:^H^G]\+\|slot
\d\d\=->\S\+\|->.\+\|\*-\*-\*-\*-\*-\)
/^\(\S\S\+.\{0,40}\S#\s*[^^G]\+\|slot
\d\d\=->\S\+.*\|->.*\|\*-\*-\*-\*-\*-\)

E488: Trailing characters


which one is line 11?
I guess it started counting from the "function()" line and skipping the
comments?
and, which line contains trailing CH?
got crazy for the whole afternoon on this ... I kind of started to hate
vimL now...
how you guys normally debug a function ?
and, I know this "simply put Ex cmds together" way is not good to write
a script, any experts points me how to improve it?
and, regardless of the script errors, sometime it does what I wanted,
but sometime doesn't, same code...is it all because of the :g magic?

Marc Weber

unread,
Aug 27, 2012, 5:56:50 PM8/27/12
to vim_use
> which one is line 11?
Exactly: 11 means 11th line of the function listed above.
https://github.com/c9s/vim-dev-plugin

has some hints about how to debug viml.

It also provides a VimLGotoLastError which often suceeds in such (line
11) cases.

We all know that viml sucks - it still often gets the job done.
Don't forgett how old vim is - and how much ahead of the time viml was
that time. No python/ruby/js/ ... existed back in time.

Today you can choose from any :h if_<tab> language implementation if you
don't like viml.

Marc Weber

ping

unread,
Aug 28, 2012, 10:41:57 AM8/28/12
to vim...@googlegroups.com, Marc Weber
thanks, guess I need invest more test to learn...

regards
ping
Reply all
Reply to author
Forward
0 new messages