Currently, whenever I switch buffers the cursor line is being centered
in the window. I have 'hidden' set and use only one window for most
tasks, using :bn and :bp to switch between buffers. I would like the
display of the buffer to remain the same between switches, so that I
don't get a centering effect of the cursor line. I have tried the
following set of autocommands, but it seems that what is executed in
BufWinEnter is being overridden by a restoration function (in C)
executed by vim whenever autocommands have completed.
autocmd BufWinLeave * let b:last_pos_mark = Mark()
autocmd BufWinEnter * if exists("b:last_pos_mark") | exe b:last_pos_mark | endif
if a:0 == 0
let mark = line(".") . "G" . virtcol(".") . "|"
let mark = "normal!" . line(".") . "Gzt" . mark
elseif a:0 == 1
return "normal!" . a:1 . "G1|"
return "normal!" . a:1 . "G" . a:2 . "|"
Does anyone have any suggestions on another way of doing this? I've
been unable to find anything in the tips section of http://www.vim.org/.
Nikolai Weibull: now available free of charge at http://bitwi.se/! Born in Chicago, IL USA; currently residing in Gothenburg, Sweden.