Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
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:
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.
augroup
,BufReadPost
andnormal!
, it actually does work. Butzz
is no-op if the current line number is too small.zz
will not do anything if centering the current line would result in a margin (empty space) at the top of the buffer.