sc wrote:
On Thursday 18 March 2010 02:32:03 am AK wrote:> Hi, I wrote a small (but nice!) plugin that works similarly to > :set number, except that it uses :signs to show line numbers > of current screen, from 1 to last screen line. It maps > <space> (via 'H') to go to [count] screen line and when no > count is given, it refreshes the numbers. > > One issue that I've run into is that there's no quick way to > determine if any lines were deleted or pasted. When a > command simply moves the screen (e.g. j on the last line), > it's easy to check location of top line of screen using > line() function - if it changed, I refresh line numbers. > > Obviously, if I deleted/added a few lines, top line of screen > number in most cases won't change, bottom line of screen > number also won't change, the line num that will change is > the last line of the file, but if I check for that, > unfortunately there's an unacceptable performance hit. I > check it using line("$"). (note that when the last line num > did not change, this check is quick, but when it did change, > it's very slow). > > Is there some trick I'm missing that could do this quickly? In > effect, something like an event NumberOfLinesInfileChanged > would be perfect.. or a workaround that does the same thing.. > or a way to speed up check for the number of last line.. > > Another related thing is that actual refreshing of :signs can > be also pretty slow, especially in insert mode and it's more > noticeable when you're working near the bottom of the screen > because you can see the numbers changing on the left side > after some delay, although that does not slow down your > input. > > Any help/advice would be great.. -ak > of more use to a lot of people is the concept of relative line numbers, for which charles wrote a plugin that uses signs, and markus has a git repository for those who build their own vim which builds the numbers into your vim instance as an added feature with the relative numbers on, whatever line the cursor is on is line 0, and the numbers increase in both directions away from current line you could probably get a lot of good ideas for your implementation by downloading and examining charles' plugin the link follows: http://www.vim.org/scripts/script.php?script_id=2351 sc
Hi, thanks for the reply. I actually thought about doing things in the same way but then the performance issue is even more acute, because with my plugin numbers don't have to refresh when you're just moving cursor around. I tried the plugin and indeed in gvim it's extremely slow when adding/deleting lines. When trying it I realized that if people somehow use it, it must work faster in console vim, and it turns out that's exactly right - console vim's redraw is as fast on deletes/adds as when just moving around. I prefer gvim for a number of reasons, so this is a bit of a disappointment.. So, a follow-up question - is there any way to have signs work faster in gvim (on ubuntu / gtk)? Thanks, -ak -- 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
