Restore View and Position of Window When Switching Buffers

When switching between buffers in the same window using <CTRL-6>, if the cursor position, lnum, is not in the middle row of the view, switching back to that buffer places the cursor position in the middle. This issue is described in a fandom wiki page as well.

I was wondering if there was a Lua based plugin or code to fix this issue? I wrote some Lua code myself but it doesn’t work as expected when switching back to a buffer for the first time because the cursor position is found to be in the middle. Subsequent buffer switches do work though. This issue is also present in the Vimscript code on the link I shared earlier.

I’m not sure why this (minor) annoyance hasn’t seen a fix yet. I feel that a fix for this issue should probably be part of upstream or part of something like kickstart.nvim.

1 Like