>
> Nick Gravgaard <[EMAIL PROTECTED]> escrit:
>
> > if Vim could display relative line numbers
> > in the left hand margin (with the current
> > line being 1, the next being 2, and so on)
>
>
> Yes, this is easy, vim can.
>
>
> This is easy implementable in vimscript
> using the *SIGNS* (:help signs).
> Plus, use the CursorMoved autocommand.
>
> Learn vim scripting yourself, or ask someone
> who has vimscript experience to write such script.
> Couple of hours if you already have experience with
> vimscript, or several days if it's your first nontrivial vim script.
I've tried it. It's my first attempt to write vim script but it seems it works.
I hope it helps you, Nick. Feel free to modify it etc.
BTW: Does some experienced vim scripter know how to define a sign with
text=' 1' (starting with a space)? I wanted to align numbers to the right but I
failed. None of "escaping" syntaxes worked.
Milan
--
Milan Vancura, Prague, Czech Republic, Europe
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---
function! RelLinesInit ()
sign define l_0 text=-- texthl=Search
let index=1
while index<=70
let sindex = (index < 10 ? "0" : "") . index
exe "sign define l_" . index . " text=" . sindex . "
texthl=Search"
let index+=1
endwhile
endfunction
function! RelLines ()
call RelLinesClear()
let lcur=line(".")
let ltop=line("w0")
let lbot=line("w$")
let index=ltop
while index <= lbot
let inum=index-lcur
let anum= inum < 0 ? -inum : inum
if anum < 70
exe "sign place " . (70 + inum) . " line=" . index . "
name=l_" . anum . " buffer=" . bufnr("%")
endif
let index+=1
endwhile
endfunction
function! RelLinesClear ()
let index=0
while index<=140
exe "silent sign unplace " . index . " buffer=" . bufnr("%")
let index+=1
endwhile
endfunction
map <silent> <special> <F11> :call RelLines()
map <silent> <special> <F12> :call RelLinesClear()
call RelLinesInit()