0

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?

  • 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 Oct 22 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 Oct 23 at 0:47

Your Answer

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

Browse other questions tagged or ask your own question.