3

I like always knowing where my cursor is. I do this by having it in the center line of the screen.

However if I am working at the top of the file the cursor stops centering because there is no more content above to display. This annoys me as sometimes I have to strain already tired eyes to find the blinking white blotch.

So the question is how would I automatically add visual white space (like the tildes ~ that populate the bottom) to the top of the file if I am at the start of file?

  • 2
    I'm pretty sure you can't do this. Have you considered using :h 'cursorline'? – Tommy A Aug 3 '16 at 14:02
  • I'm also pretty sure of the same, but sometimes I am pleasantly surprised. :h cursor line will help, but does not fix. – Jason Basanese Aug 3 '16 at 14:07
  • Focus.vim isn't exactly what you want, but sorta achieves this IIRC. – DJMcMayhem Aug 3 '16 at 14:13
  • Focus.vim wasn't what I was looking for but that is actually awesome. – Jason Basanese Aug 3 '16 at 16:31
3

zz does what you want, sort of, but it doesn't work near the top of the file, nor near the bottom (when the file is too short).

There is another way to keep track of the cursor, by highlighting cursor's line and column:

:set cursorline cursorcolumn

But there is a price to pay for it though, these settings can slow down scrolling for some filetypes.

  • I knew about zz and Tommy mentioned cursorline, but hopefully cursor column wil help. – Jason Basanese Aug 3 '16 at 15:28
  • After using for a little while I find this is sufficient, as nice as always knowing your cursor is in the center would be. – Jason Basanese Aug 3 '16 at 16:15
  • @JasonBasanese It's mostly fine, but as I said, with some filetypes you just draw the short stick. shrug – Sato Katsura Aug 3 '16 at 16:42
  • This minimizes the lag by allowing you to toggle. tdi.github.io/2013/01/30/toggle-cursorline-in-vim – Jason Basanese Aug 3 '16 at 17:25
  • 1
    @JasonBasanese That's just a complicated (and somewhat broken) way of doing this: nnoremap <silent> <leader>cl :set cul! cuc!<CR>. It doesn't solve the problem, it just makes it more convenient to take the quick exit. – Sato Katsura Aug 3 '16 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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