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
--
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