Paul Isambert <[email protected]> [13-06-09 20:28]: > [email protected] a écrit: > > Hi, > > > > I have a loooong line "of text" (it is not really text...) with a > > bunch of pipe symbols ("|") in it. The distance between the bars > > differ. > > And I am to lazy to do the error prone job to count the spaces... > > > > Is there a easy way to ask vim to do that for me? > > Best would be if it would put the count of spaces right below > > the according "|".... > > > > May be certain trick with search and replace ??? > > I’m not sure I understand you correctly, but perhaps the following > will help: > > function! s:bars () > let newline = "" > let lineno = line(".") > let str = getline(lineno) > let cnt = stridx(str, "|") > let offset = 0 > while cnt >= 0 > let newline .= repeat(" ", cnt-offset) . cnt > let offset = strlen(cnt)-1 > let str = strpart(str, cnt+1) > let cnt = stridx(str, "|") > endwhile > call append(lineno, newline) > endfunction > com! -buffer Bars call s:bars() > > Calling “:Bars” with the cursor on a line like: > | | | | abcde | | > produces: > | | | | abcde | | > 0 12 3 10 7 1 > > So it really counts the number of *characters* between bars. If you > really want only spaces to count (so that “7” here would be “2”), > it’ll require a little bit more work. > > (I’m sure there’s a Vim wizard out there who can do all that with only > “:substitute”.) > > Best, > Paul > > -- > -- > 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 > > --- > You received this message because you are subscribed to the Google Groups > "vim_use" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > >
Hi Paul, yes,yes,yes,!!! Exactly what I want! THANKS A LOT! You helped me more as you may think :) ! Great help! 8) Have a nice evening! Best regards, mcc -- -- 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 --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
