Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why might Vim quit when the ‘:bdelete’ command is run?

Tags:

vim

According to the answer of this question, the :bd command should not quit Vim (gVim) when it is the last buffer remaining. Unfortunately, it does close gVim in my case. Did I understand something wrong about :bd?

I am also using a preconfigured vimrc file. Maybe a setting in there has that side affect, but I couldn’t find it.

like image 592
Zardoz Avatar asked Apr 24 '11 01:04

Zardoz


1 Answers

Try doing the following:

:set eventignore=all | bd | set eventignore=

If this won't quit vim then you have some plugin that defines an autocommand that quits vim when no more buffers are present in the list, so after that try doing

verbose autocmd BufWinLeave,BufLeave,BufDelete,BufUnload,BufWipeout

This will show you all autocommands attached to given events (these are events that are executed when buffer is deleted) and where they were defined. Note that I do not have any autocommands attached to these events that are defined by plugins in standart vim distribution.

Update: I do not see anything bad in your output. You may also try

verbose autocmd BufNew,BufAdd,BufCreate,BufEnter,BufWinEnter

(because when you leave last buffer new empty one is created). If this does not show anything suspicious, start ignoring event types: if you are on linux try the following script:

for event in BufWinLeave BufLeave BufDelete BufUnload BufWipeout BufNew BufAdd BufCreate BufEnter BufWinEnter
do
    event=$event vim file -c "set eventignore=$event | bd"
done

This script should iterate until you find event name that causes trouble. After this you can use execute "verbose autocmd" $event in vim to narrow number of plugins that should be checked. After you got list of autocmd groups (augroup names are shown just before event name in your output: railsPluginDetect is one of such groups), delete events in them (augroup {GroupName} | execute 'autocmd!' | augroup END) and find out which plugin to claim.

Alternatively, you can use debugger:

debug bd

, then s<CR>n<CR><CR><CR>... until vim quits; don't forget to remember what vim have shown above > prompt before quiting.

like image 193
ZyX Avatar answered Nov 02 '22 00:11

ZyX