Is it possible to :e a buffer in vim without having the scrolling adjusted?

The behavior I see: the file is reloaded followed by a zz (redraw with line count at center of window). I'd like to just reload the file.

  • Well, you could map over zz or :e to mark your position, run the original command then and then return to that spot. But, that's ugly and I would hope there is a better way to solve this.
    – Shadoath
    Nov 13 '17 at 2:51

The anwolib plugin has a :KeepView command that modifies any Ex command to keep the current window layout. You can then use

:KeepView edit!

to reload while keeping the current view.

Alternatively, you can implement this yourself using winsaveview() and winrestview().

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.