Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to make zt and zb commands move cursor to really first and last lines of the window. #28

Closed
anuvyklack opened this issue Jun 13, 2021 · 7 comments

Comments

@anuvyklack
Copy link

The title says it all.

@karb94
Copy link
Owner

karb94 commented Jun 13, 2021

Are you aware that the current behaviour is the default behaviour in vanilla (neo)vim? If you want the screen to scroll until the cursor is at the first/last line of the window then you can simply set scrolloff=0.

If I'm missinterpreting the title please explain further what you want.

@anuvyklack
Copy link
Author

anuvyklack commented Jun 13, 2021

According to :help zt it should puts current line at top of window. But currently, for me, it puts cursor at the first quarter line at window.


Edited, because misunderstood your answer at first.

@anuvyklack
Copy link
Author

My scrolloff option is 0.

@karb94
Copy link
Owner

karb94 commented Jun 13, 2021

According to :help zt it should puts current line at top of window

This is true as long as scrolloff=0. Try opening a file with nvim -Nu NONE and then :set scrolloff=5. You'll see that the cursor does not go to the top of the screen if you press zt (unless you are at the top of the file).

Can you please run :set scrolloff=0 and check again if zt/zb brings the cursor to the top/bottom of the window? This issue could be related to #11 somehow.

@anuvyklack
Copy link
Author

anuvyklack commented Jun 13, 2021

Yes, it is related to #11 .

  • set scrolloff? returns 0;
  • set scrolloff=0 doesn't help;
  • setlocal scrolloff? returns -1;
  • setlocal scrolloff=0 fix the problem;
  • And the most interesting: :lua print(vim.wo.scrolloff) somewhy returns 9, which is the root of the problem.

@karb94
Copy link
Owner

karb94 commented Jun 13, 2021

Yes... So I tried to provide a workaround to neovim/neovim#13964 in #11 but it will break when the garbage value of local scrolloff is between 0 and half of the window size. I can't do any better than this until the neovim issue is fixed because I have no way of knowing if you set that local scrolloff=9 or is a garbage value. However, you can fix this by explicitly setting the local scrolloff in your vimrc (setlocal scrolloff=0).

@karb94 karb94 closed this as completed Jun 13, 2021
@anuvyklack
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants