문제

In Vim we can travel to different lines using ':<line-number>'.

And we can also sync the screen by typing 'zt' in normal mode.

But how do we have the screen get synced automatically every time we go to a specific line?

도움이 되었습니까?

해결책

If by syncing you mean centering the line at the top (what zt does) / middle / bottom, you can achieve an always-on centering of the current line in the middle via:

:set scrolloff=999

For all other, I'd recommend a custom G mapping:

:nnoremap G Gzt

To make this also work with :[N] and all other jump commands, you'd have to define :autocmds, and I would recommend against that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top