numbering lines in groups

Thanks to this list I have "grouped" line numbering working.

It is not a normal sequential numbering, but in groups of n lines.

Example n=2
(    1_0_)
(    1_1_)
(    1_2_)
(    2_0_)
(    2_1_)
(    2_2_)
(    3_0_)
(    3_1_)
(    3_2_)
(    4_0_)
(    4_1_)
(    4_2_)

I had a problem when using n=15 as follows, it worked like n=2. I
discovered that only the first "digit" was being compared @l<@n, seems
to be a string compare.
--THIS FAILS--
vmap <F5> :<C-U>let @n=15 <BAR> let @b=1 <BAR> let @l=0 <BAR>
  \ '<,'>s/^/\=printf("( %4d_%X_)",
  \ @b + setreg('b', @l<@n ? @b : @b+1 ),
  \ @l + setreg('l', @l<@n ? @l+1 : 0 ))<cr>
endif

So I tried using a variable instead of a register and it worked.
--THIS WORKS--
vmap <F5> :<C-U>let n=15 <BAR> let @b=1 <BAR> let @l=0 <BAR>
  \ '<,'>s/^/\=printf("( %4d_%X_)",
  \ @b + setreg('b', @l<n ? @b : @b+1 ),
  \ @l + setreg('l', @l<n ? @l+1 : 0 ))<cr>
endif

Then searching the excellent vim help found str2nr(), said I, ok!
--THIS WORKS--
vmap <F5> :<C-U>let @n=15 <BAR> let @b=1 <BAR> let @l=0 <BAR>
  \ '<,'>s/^/\=printf("( %4d_%X_)",
  \ @b + setreg('b', @l<str2nr(@n) ? @b : @b+1 ),
  \ @l + setreg('l', @l<str2nr(@n) ? @l+1 : 0 ))<cr>
endif

QUESTION: Why does @l<n work and @l<@n fail? Where do I find help?

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to