Markus wrote: > I have adapted my relativenumber patch to Vim 7.2a, initial version was from > 21.02.2008. Unfortunately it didn't get into mainline yet. > > Short description: > Set the new option 'relativenumber' or 'rnu' to display relative line numbers. > With it you can just read the values for [count], that is used in very many > commands (e.g. j k + - y d c < > gq gw =), without calculating it by yourself. > This evolves the power of the count mechanism more than ever.
Hi, I remember Nick Gravgaard already needed such option and I wrote a simple vim script doing that, with no patch. It is not ideal of course (no events used, for example - one must press a hot key with this alpha version of the script) but it shows the problem probably has a solution even using vim script language only. What do you think? Milan P.S.: the old e-mail with the script: > > > > 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 > > > > 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() --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---