Please do the following (unix vim7.2.394):
1) With "set nohidden" in .vimrc (default)
gvim file1
Put the cursor on line 4, column 10 (not line 1)
:e file2
Use Menu/Buffers/Previous (or :bprevious)
Buffer file1 is reopened with cursor on line 4, column 10
Explanation: with "set nohidden", file1 is really closed so that :bp
reopens it with the autocmd g`" executed.
2) With "set hidden" in .vimrc
gvim file1
Put the cursor on line 4, column 10 (not line 1)
:e file2
Use Menu/Buffers/Previous (or :bprevious)
Buffer file1 is reopened with cursor on line 4, colum 1
(Idem for any line).
Do you reproduce that?
It looks like a bug.
Best regards
Jean Johner
This is expected behavior. See ":help 'startofline". You'll likely
want to ":set nostartofline" for the behavior you desire.
--
James
GPG Key: 1024D/61326D40 2003-09-02 James Vega <jame...@jamessan.com>
Hi James,
Setting "nostartofline" solves the problem, but it results in keeping
the cursor column also for CTRL-F, gg ... which in my opinion is not
natural.
Presently, the situation is as follows:
1)
set sol (default)
set nohidden (default)
autocmd g`" in .vimrc (default .vimrc)
Result: the cursor column is remembered with :bprevious
2)
set sol (default)
set hidden (to be able to edit a new buffer without
saving)
autocmd g`" in .vimrc (default .vimrc)
Result: the cursor column is NOT remembered with :bprevious
In my opinion, the cursor column should be remembered in case 2)
Best regards
Jean Johner
Which is run on BufReadPost (if it's the autocmd listed at ":help
last-position-jump"). That happens here because when 'nohidden' is set
and you switch buffers, the buffer is unloaded. When you switch back to
that buffer, it is re-read from disk, therefore the BufReadPost autocmd
is executed.
> Result: the cursor column is remembered with :bprevious
>
> 2)
> set sol (default)
> set hidden (to be able to edit a new buffer without
> saving)
> autocmd g`" in .vimrc (default .vimrc)
In this situation, the BufReadPost autocmd isn't being run because the
buffer is still in memory. You could try also running the autocmd on
BufEnter in order to achieve your desired behavior.
> Result: the cursor column is NOT remembered with :bprevious
Note that there is no "default" vimrc. There's an example vimrc that's
shipped with Vim and some Linux distributions provide a system-wide
vimrc that is sourced before the user's vimrc.
Thank you James
Jean Johner