When toggling folds with zi, any folds expanding above the current line cause the current line to disorientingly jump to a different place on the screen.
How can I keep the current line fixed in the same place while toggling folds?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
You could create a mapping and use it instead of using zi. Create a mark for the current position and one for the top of the visible buffer, apply zi, move to the top, move the buffer, then move back to the original position.
nnoremap <Leader>zi maHmb'azi'bzt`a