When I switch buffer and then go back to it (when I get back to any buffer that was previously opened), cursor is placed in the middle of the screen, loosing previous screen position (e.g. cursor at top of the screen). Maybe this is the normal behaviour of vim, but is there any way to fix this?
This problem happens when I use :bn and bp: to switch buffers. However this behaviour does not happen when switching between tabs which is really strange.
See http://vim.wikia.com/wiki/Avoid_scrolling_when_switch_buffers
" When switching buffers, preserve window view.
if v:version >= 700
au BufLeave * if !&diff | let b:winview = winsaveview() | endif
au BufEnter * if exists('b:winview') && !&diff | call winrestview(b:winview) | endif
endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With