18

I have just discovered the :bwipeout command, for which the :help states:

Like :bdelete, but really delete the buffer. Everything related to the buffer is lost. All marks in this buffer become invalid, option settings are lost, etc. Don't use this unless you know what you are doing.

Other than the obvious, I'm unclear on what the downside to using this command is.

My option settings will almost always be reset to the same values when I next open the file in question, and losing my marks doesn't seem to warrant the ominous warning: "Don't use this unless you know what you are doing."

What is included in the "etc.", and what terrible consequences could there be that I'm not foreseeing?

1 Answer 1

24

"Bad" is a bit relative (your hard drive won't be erased or anything).

bdelete makes the buffer unlisted, but doesn't purge marks, options, the buffer name, the buffer number, and so on. If you reload the buffer that information is retained (less what may be modified by autocommands), which may be useful because

  • it allows you to keep using any marks, or the buffer number, you may have in your short-term memory.
  • it prevents vim from having to reparse viminfo for the relevant information (trading the cost of keeping that info in RAM for the cost of reading that file from the disk, which is admittedly something we don't generally need to consciously worry about that much on modern computers).

bwipeout, on the other, gets rid of all of that (everything that is associated with the buffer), so that if you reopen the buffer it will be as if vim never saw that buffer before during this session.

It's not really as "dangerous" as the documentation implies. I presume the dire writing is simply to warn you that wiping out a buffer is significantly more destructive of an action than simply deleting it.

2
  • 6
    ... which suggests that they could have chosen names [:bremove,:bdelete] instead of [:bdelete,:bwipeout].
    – Enlico
    Commented Sep 2, 2020 at 14:59
  • 1
    @Enlico I'd suggest :bunlist / :bdelete Commented May 22 at 11:27

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.