Undead buffer: gets deleted but respawns on session launch

50 views
Skip to first unread message

Sylvia Ganush

unread,
Apr 23, 2013, 11:41:08 AM4/23/13
to v...@vim.org
Good day.

What may cause a deleted buffer to reappear on session launch?

I once edited a file, a Figlet font. I deleted the buffer, and
then exited Vim as I usually do:

:mksession! session.vim
:wqa

But when restart the session the deleted buffer is still present on the
:ls list. The buffer itself is empty. A 'ghost', if you wish.

What gives?

Regards,

Sylvia

Ben Fritz

unread,
Apr 23, 2013, 1:06:31 PM4/23/13
to vim...@googlegroups.com, v...@vim.org, sga...@me.com
On Tuesday, April 23, 2013 10:41:08 AM UTC-5, Sylvia Ganush wrote:
>
> What may cause a deleted buffer to reappear on session launch?
>

Maybe you have the % character in your 'viminfo' option? You said you deleted the buffer, though, so I'd expect it would not be in the saved list. What command did you use to delete the buffer?

Tony Mechelynck

unread,
Apr 23, 2013, 4:01:21 PM4/23/13
to vim...@googlegroups.com
The :ls! list (but not the :ls list without bang) contains buffers
previously edited, even if deleted.

See ":help :bwipeout" and the last paragraph under ":help :bdelete". See
also ":help unlisted-buffer".


Best regards,
Tony.
--
According to the obituary notices, a mean and unimportant person never
dies.

Sylvia Ganush

unread,
Apr 24, 2013, 2:56:09 PM4/24/13
to vim...@googlegroups.com
Hi Ben.

Here's my 'viminfo' option:

viminfo='100,<50,s10,h,rA:,rB:

No '%' in there. The ghost buffer always has '#h' in front of its name.

To delete the buffer I do:

:bd!

Sylvia

Ben Fritz

unread,
Apr 24, 2013, 6:06:06 PM4/24/13
to vim...@googlegroups.com, v...@vim.org, sga...@me.com
On Tuesday, April 23, 2013 10:41:08 AM UTC-5, Sylvia Ganush wrote:
:help :mksession says:

7. Reloads the buffer list, with the last cursor positions. If
'sessionoptions' contains "buffers" then all buffers are restored,
including hidden and unloaded buffers. Otherwise only buffers in windows
are restored.

So, after reading Tony's response, I expect you could solve this either by removing 'buffers' from your sessionoptions, or by using :bwipe instead of :bd to delete the buffer.

Tony Mechelynck

unread,
Apr 25, 2013, 2:21:42 AM4/25/13
to vim...@googlegroups.com
#h means a hidden buffer, which is the alternate buffer (i.e. usually
the last buffer you edited before the current one).

Try :bw! instead of :bd! and see if there is a difference. But beware!
:bw forgets *everything* that Vim has in memory concerning that buffer.


Best regards,
Tony.
--
FIGHTING WORDS

Say my love is easy had,
Say I'm bitten raw with pride,
Say I am too often sad --
Still behold me at your side.

Say I'm neither brave nor young,
Say I woo and coddle care,
Say the devil touched my tongue --
Still you have my heart to wear.

But say my verses do not scan,
And I get me another man!
-- Dorothy Parker

Sylvia Ganush

unread,
Apr 25, 2013, 11:58:03 AM4/25/13
to vim...@googlegroups.com

On 25 Apr 2013, at 00:06, Ben Fritz <fritzo...@gmail.com> wrote:

> So, after reading Tony's response, I expect you could solve this either by removing 'buffers' from your sessionoptions, or by using :bwipe instead of :bd to delete the buffer.

Thank you Ben, thank you Tony.

I gave up and simply recreated the session.

The offending buffer just wouldn't die no matter what. ':bw!' didn't get it,
nor did ':set sessionoptions-=buffers'.

Maybe I was doing something wrong, but I open dozens of other files and delete
the respective buffers, but only this one stuck inside the session for some
reason. The stars must have aligned in a certain way at its birth. ;-)

Sylvia

Victoria Stuart

unread,
Jan 17, 2017, 1:27:03 AM1/17/17
to vim_use, v...@vim.org, sga...@me.com
http://stackoverflow.com/questions/5238251/deleting-buffer-from-vim-session/41683144#41683144



Ok: this was annoying me, too. I have a command (Arch Linux: Krusader file manager)

vim --remote

that enables me to right-click a file in Krusader and open that fike in Vim. I also save Vim sessions via my ~/.vimrc:

" Save session on quitting Vim:
autocmd! VimLeave * mksession! ~/.vim/vim_session.vim
" mksession! overwrites old session

" Restore session on starting Vim:
autocmd! VimEnter * source ~/.vim/vim_session.vim

However, a file I opened externally via vim --remote, e.g.

/mnt/Vancouver/Programming/scripts/chunk.sh

stubbornly persists between sessions, even after doing the usual :bd, :bw, :bw! etc. commands, and/or deleting the vim session file.

Looking at the vim_session.vim file, I noted an 'argadd' line with the offending, persistent file:

argadd /mnt/Vancouver/Programming/scripts/chunk.sh

So,

:help arglist

:argd /mnt/Vancouver/Programming/scripts/chunk.sh
" delete that arg

Finally, clear that file from the buffer list (:bd). Restart Vim: the previous session is restored, minus that file.

Felipe Vieira

unread,
Jan 18, 2017, 9:43:42 AM1/18/17
to vim_use, v...@vim.org, sga...@me.com
I have reported the same problem:

https://groups.google.com/forum/#!topic/vim_use/qL4--7akXS4

Looks like you are not the only one.

Since we found a workaround but the behavior seems to be wrong I have opened a github issue:

https://github.com/vim/vim/issues/1393

Reply all
Reply to author
Forward
0 new messages