As title. I'm trying to call bd #
while it fails when the previous buffer doesn't exist. So my question is how to detect this?
1 Answer
The previous buffer (any buffer) number can be obtained via
echo bufnr('#')
If the buffer is invalid, this will return -1, otherwise it is the number of the buffer.