vim

Vim: Close All Buffers But This One


How can I close all buffers in Vim except the one I am currently editing?


Solution

  • You could use this script from vim.org:

    http://www.vim.org/scripts/script.php?script_id=1071

    Just put it to your .vim/plugin directory and then use :BufOnly command to close all buffers but the active one. You could also map it elsewhere you like in your .vimrc.

    Source on Github (via vim-scripts mirror): https://github.com/vim-scripts/BufOnly.vim/blob/master/plugin/BufOnly.vim