Am 07.02.2010 17:16, schrieb Stahlman Family:
Consider the following test sequence...
:new
:ls
1 #a "[No Name]" line 1
2 %a "[No Name]" line 1
:hide
:ls
1 %a "[No Name]" line 1
2 h "[No Name]" line 0
:new somefile.txt
:ls
1 #a "[No Name]" line 1
2 h "[No Name]" line 0
3 %a "somefile.txt" line 1

As expected, the empty [No Name] buffer created with :new was hidden by
the :hide command and remains in the buffer list. I can get it back in
its own window by executing...
:sb 2

Now consider the following variation on the test sequence above...
:new
:ls
1 #a "[No Name]" line 1
2 %a "[No Name]" line 1
:hide e somefile.txt
:ls
1 a "[No Name]" line 1
2 %a "somefile.txt" line 1

Notice that the [No Name] buffer that used to be buffer 2 is now gone,
apparently replaced by somefile.txt. I can't possibly get it back. I
know it was discarded (and not simply reassigned the name somefile.txt)
because any buffer-local variables it contained are not accessible in
the somefile.txt buffer.

It seems to me that the 2 test cases above should produce similar
results. In particular, I would expect that executing...
:sb 2
...at the end of the second sequence would restore to its own window the
[No Name] buffer hidden by...
:hide e somefile.txt

Is this a bug, or is the behavior described somewhere in the documentation?

Thanks,
Brett Stahlman

This reminds me of :enew (where it's undocumented, too).

When the current buffer is unnamed and empty ('buftype' doesn't matter),
:enew will reuse its number.

What will get lost from the old buffer:
- buffer local variables
- undo history
(99% of unnamed and empty buffers will not have any of them)

This is only what I checked, not a complete list.

I think Vim just tries to be smart and not waste buffer numbers ...
which isusually ok for me.

--
Andy

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to