I use NERDTree and try to apply the recipe that ensures no one replaces its buffer.
I do the following:
- Start vim
- Execute
:NERDTreeFocus
- Open some file
- Execute
:q
for file buffer - (At this point there is one window with NERDTree only)
- Open some other file
There I have NERDTree and former file buffers swapped.
While trying to track down the issue I found the following. Suppose we have this autocmd:
autocmd BufEnter * echomsg "Alternate: " . bufnr('#') . " " . bufname('#') | echomsg "Current: " . bufnr('%') . " " . bufname('%')
Then I try:
- Start vim
:vs
:e 123
<C-W> j
<C-W> l
After step 3 I see the following in messages:
"123" [New]
Alternate: 1
Current: 2 123
After step 4:
Alternate: -1
Current: 1
After step 5:
Alternate: 1
Current: 2 123
My question is: why do I have Alternate: -1
after step 4 instead of Alternate: 2 123
?