On 19/01/11 5:44 AM, Randy Morris wrote:
Hello all,

I am currently writing a buffer explorer type of plugin and am finding
that in at least one specific use case bufnr('#') is "wrong".  I was
hoping someone may be able to shed some light as to if it's just my
interpretation that is wrong.

vim -u NONE --noplugin
:echo bufnr('%') =>  1
:echo bufnr('#') =>  -1
:e foo
:echo bufnr('%') =>  1
:echo bufnr('#') =>  1

If the buffer number of the current buffer does not change, why does the
number of the alternate buffer change?

Well, I can understand why it happens.

Buffer 1 was indeed the last buffer edited in that window, so it's the
alternate buffer.

It's just that because you were editing the empty unnamed initial
buffer, its buffer number got reused as well, so buffer 1 is also the
buffer currently being edited in the window--i.e. '%' didn't change as
it normally would. It's only because of that corner case of reusing the
empty buffer that you're seeing the strangeness. Normally if you :e foo,
the old '%' will become the new '#', and '%' will change to some other
number.

I think.

Ben.



--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to