Sunday, June 9, 2013

Re: Measuring lines

On Sun, Jun 09, 2013 at 07:57:23PM +0200, meino.cramer@gmx.de wrote:
> 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 ???

this is probably not what you had in mind, but I've had a lot of fun
with the following combination of iabbr and function:

iabbrev <silent> rul1 <c-r>=Scaleme(10)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul10 <c-r>=Scaleme(100)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul11 <c-r>=Scaleme(110)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul12 <c-r>=Scaleme(120)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul13 <c-r>=Scaleme(130)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul14 <c-r>=Scaleme(140)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul15 <c-r>=Scaleme(150)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul2 <c-r>=Scaleme(20)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul3 <c-r>=Scaleme(30)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul4 <c-r>=Scaleme(40)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul5 <c-r>=Scaleme(50)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul6 <c-r>=Scaleme(60)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul7 <c-r>=Scaleme(70)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul8 <c-r>=Scaleme(80)<CR><c-r>=Eatchar('\s')<cr>
iabbrev <silent> rul9 <c-r>=Scaleme(90)<CR><c-r>=Eatchar('\s')<cr>

function! Scaleme(w)
let c = 0
let str = ""
while c < a:w
let c += 1
if c % 5 == 0
if c % 10 == 0
let a = (c / 10)[-1:]
else
let a = "+"
endif
else
let a = "."
endif
let str = str . a
endwhile
return str
endfunction

you could put a scale line above your long text line and see which
columns each pipe were in...

(Eatchar is a direct rip from :help iabbreviation)

--
_|_ _ __|_|_ ._ o|
|_(_)(_)|_| ||_)||<
|

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: