You are getting this error from running in Ex-mode, which in your case you're getting through passing Vim the
-e command-line argument, but you could equally get there by running the
ex command directly (instead of
vim), or using the
Q Normal-mode command to enter Ex-mode.
The error message is coming from this line in
do_exmode(), which implements the Ex-mode loop. After running an Ex command, it will perform some checks and raise error
E749 if the buffer is empty.
Digging into history of this code, it seems this behavior was introduced in Vim version 7.0051, from February 2005, so it's been this way for a long time.
Looking at the code around that line, there's another error that might be raised there, which is
E501: At end-of-file, which is raised if you press enter on the Ex prompt (i.e.
:<CR>) while you're at the last line of the buffer. Pressing enter on the Ex prompt will advance you to the next line. In light of that behavior, it makes sense that doing so at the end of the buffer will raise an error.
An empty buffer is, in a sense, a corner case of that, since technically you're at or past the last line of the buffer, even though you're also at the first and only line. That probably justifies raising an error in that situation, and the authors probably picked
E749: empty buffer as it's more descriptive than the
There doesn't seem to be a workaround for this issue. Maybe you can avoid using Ex-mode? Maybe you can avoid the situation where the buffer gets completely empty? But indeed
:try won't help, because the error is not really coming from the
:delete command, but from the Ex-mode loop, after the command has emptied the buffer.