1

As title. Would the buffer I set the option with the value delete really get deleted immediately? If not, when will it be deleted and what is this mechanism? Sorry for maybe a bad question but I'm trying to learn Vim's buffers mechanism.

Btw, I also read a special type of buffers called directory and these buffers have this option set to delete from the start. So I guess my intuition could be correct that these buffers are "about to be deleted" but I'm still curious about what will happen behind the scene. (If that's the case, then I also want to know whether "recovery from a set-to-delete buffer" is possible.)

1 Answer 1

1

Would the buffer I set the option with the value delete really get deleted immediately? If not, when will it be deleted and what is this mechanism?

"When" stands for "when buffer is not displayed in any window anymore", or, in other words, when BufWinLeave event gets triggered.

"What" is "bdelete" command (or equivalent).

Also, there's no "directory" buftype. If some buffer gets "bufhidden" non-empty value then it should be due to a plugin.

8
  • "Also, there's no "directory" buftype": Yes, there is. I'm using neovim and it's under the section :h special-buffers. The title of that manual is VIM REFERENCE MANUAL by Bram Moolenaar. Commented Jan 24, 2023 at 18:11
  • "when BufWinLeave event gets triggered": Do you have any reference for your words? Commented Jan 24, 2023 at 18:19
  • 1
    Your problem that you read very unattentively. The buftype option value is "nofile". "Directory" is "kind of", that is an informal explanation what that thing could be used for. It appears nowhere else. Also, I don't understand what is "a reference"? I tell what I know, and I know pretty much, when it comes to Vim, I dare say.
    – Matt
    Commented Jan 24, 2023 at 18:35
  • OK, I believe your words. So my conclusion is: This kind of buffer "directory" is a buffer that will be deleted immediately on BufWinLeave when it disappears from all of my tabpages. By "deleted" it means the data structure will be freed (so it's null, not just empty), correct? Commented Jan 24, 2023 at 18:45
  • 1
    What it does is "bdelete". But what exactly does "bdelete" is yet another question.
    – Matt
    Commented Jan 24, 2023 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.