Code Monkey home page Code Monkey logo

vim-bbye's Introduction

Bbye (Buffer Bye) for Vim

Bbye allows you to do delete buffers (close files) without closing your windows or messing up your layout.

Vim by default closes all windows that have the buffer (file) open when you do :bdelete. If you've just got your splits and columns perfectly tuned, having them messed up equals a punch in the face and that's no way to tango.

Bbye gives you :BbyeDelete and :BbyeWipeout commands that behave like well designed citizens:

  • Close and remove the buffer.
  • Show another file in that window.
  • Show an empty file if you've got no other files open.
  • Do not leave useless [no file] buffers if you decide to edit another file in that window.
  • Work even if a file's open in multiple windows.
  • Work a-okay with various buffer explorers and tabbars.

Regain your throne as king of buffers!

Installing

The easiest and most modular way is to download Bbye to ~/.vim/bundle:

mkdir -p ~/.vim/bundle/bbye

Using Git:

git clone https://github.com/tanner-d/vim-bbye.git ~/.vim/bundle/bbye

Using Wget:

wget https://github.com/tanner-d/vim-bbye/archive/master.tar.gz -O- | tar -xf- --strip-components 1 -C ~/.vim/bundle/bbye

Then prepend that directory to Vim's &runtimepath (or use Pathogen):

set runtimepath^=~/.vim/bundle/bbye

Using

Instead of :bdelete and :bwipeout, use :BbyeDelete and :BbyeWipeout respectively.

As it's likely you'll be using :BbyeDelete often, make a shortcut to \q, for example, to save time. Throw this to your vimrc:

:nnoremap <Leader>q :BbyeDelete<CR>

Buffer delete vs wipeout

Vim has two commands for closing a buffer: :bdelete and :bwipeout. The former removes the file from the buffer list, clears its options, variables and mappings. However, it remains in the jumplist, so Ctrl-o takes you back and reopens the file. If that's not what you want, use :bwipeout or Bbye's equivalent :BbyeWipeout where you would've used :bdelete.

Closing all open buffers and files

Occasionally you'll want to close all open buffers and files while leaving your pristine window setup as is. That's easy. Just do:

:bufdo :BbyeDelete

For some variations, like closing all-but-one buffer, see @qiushihe's script in moll#4.

Aliasing to :Bclose

If you've used any Bclose.vim scripts before and for some reason need the :Bclose command to exist, you may make an alias:

command! -bang -complete=buffer -nargs=? Bclose BbyeDelete<bang> <args>

License

Bbye is released under a Lesser GNU Affero General Public License, which in summary means:

  • You can use this program for no cost.
  • You can use this program for both personal and commercial reasons.
  • You do not have to share your own program's code which uses this program.
  • You have to share modifications (e.g bug-fixes) you've made to this program.

For more convoluted language, see the LICENSE file.

About

Andri Möll authored this in SublemacslipseMate++.
Monday Calendar supported the engineering work.
Inspired by Bclose.vim, but rewritten to be perfect.

If you find Bbye needs improving or you've got a question, please don't hesitate to email me anytime at [email protected] or create an issue online.

vim-bbye's People

Contributors

moll avatar juanibiapina avatar skjaleidoscope avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.