1

I would like to execute 'zz' to center the current line to the center of the screen when opening a new file. I have tried the following, but it does not seem to be working for some reason:

autocmd BufEnter * :normal zz

Any ideas?

2
  • 3
    Leaving aside that you should use augroup, BufReadPost and normal!, it actually does work. But zz is no-op if the current line number is too small.
    – Matt
    Commented Oct 22, 2019 at 19:48
  • 2
    Repeating what Matt said but in different terms (which may or may not help): zz will not do anything if centering the current line would result in a margin (empty space) at the top of the buffer.
    – B Layer
    Commented Oct 23, 2019 at 0:47

0

Your Answer

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

Browse other questions tagged or ask your own question.