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.