0

The rightmost entry of the status line changes erratically.

Reproduce:

  1. vim --clean
  2. :set number
  3. o<Esc>98.
  4. Press and hold k

The rightmost entry of the status line first says Bot and only switches to 98% when I am at line 82. It then keeps decreasing until it reaches 1% at line 7 and then switches to Top at line 6. If you now press and hold j to go back, it only switches to 1% at line 19, then increases and reaches Bot at line 95.

All of this depends on the terminal window size.

Is this behavior desired? If yes, how is the right most entry useful then?

1
  • If you want to change it, it’s not terrible to just roll your own statusline. I switched to this after using airline for a long time and I dont miss it.
    – D. Ben Knoble
    Dec 18, 2018 at 17:47

2 Answers 2

4

This information comes from the function get_rel_pos from the buffer.c of the Vim source file. What it does, it calculates the window position of the current view with respect to the complete buffer content. The function itself is rather short, as you can see:

enter image description here

What it does, it checks the line above the current top window line and below the current bottom window for its values. If there is no line above and below, it will print All, if there is no line above it will print Top and if there is not line below it will print Bot (all of which will might be translated), else it will calculate the percentage.

That also means, that using H, M and L for moving the cursor within the current window, won't change the positional info.

1
  • 1
    I understand the formula, but I still have no idea why this would be more helpful than current/total*100
    – Bananach
    Dec 18, 2018 at 15:36
1

This percentage doesn't show percent of where the cursor is, but rather buffer view. Like in the docs (from :h 'statusline'):

Percentage through file of displayed window

Note, that this changes when you reach top or bottom of the visible lines in a window, and when that window starts to scroll when you move up or down. It's easier to see when you :set scrolloff=40 (or anything larger then half of lines visible in Vim instance)

how is right most entry useful then?

I find it usefull with larger files, it shows more or less where you are in the document while travelling across it, or in manuals, since I use Vim as man viewier.

2
  • but you agree it would be strictly more useful if it just displayed currentline/totalnumberoflines*100?
    – Bananach
    Dec 18, 2018 at 15:33
  • Nope, I like it as it is, for large files you wouldn't even notice the difference
    – grodzik
    Dec 18, 2018 at 22:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.