Nafaa Boutefer
Nafaa Boutefer

Reputation: 2359

How to remove buffer from jumplist in vim

How could I delete a buffer and remove it from the jumplist? so that the next time I hit <CTRL-o> or <CTRL-i> it doesn't open it again.

Upvotes: 2

Views: 1114

Answers (1)

Nafaa Boutefer
Nafaa Boutefer

Reputation: 2359

To do that you should use one of the built-in commands provided by vim

:bdelete that only closes the buffer and replace it with the one next to it in the jumplist unless there are changed that has not been saved, if you want to delete the buffer and discard the changes :bdelete! is what should be used.

The problem with :bdelete[!] is that only the buffer will be deleted but everything else related to it will stay there like it's position in the jumplit and the marks that registered on it and so on.

So the second command that I find very powerful is :bwipeout[!] which will remove the buffer completely and all the metadata related to it.

With both these commands you can specify counters and ranges, for example:

to delete all buffers use :%bd[elete][!]

to delete all buffers from buffer number 4 to the last one use :4,$bdelete[!] and so on.

the same goes for :bwipeout[!]

Upvotes: 1

Related Questions