≡

wincent.dev

  • Products
  • Blog
  • Wiki
  • Issues
You are viewing an historical archive of past issues. Please report new issues to the appropriate project issue tracker on GitHub.
Home » Issues » Feature request #1868

Feature request #1868: Shortcut to close a buffer in :CommandTBuffer popup menu

Kind feature request
Product Command-T
When Created 2011-09-05T15:13:23Z, updated 2012-08-11T18:52:42Z
Status closed
Reporter anonymous
Tags no tags

Description

Use case: After working on a project for a while, tons of buffer gather up cluttering the editor. Currently the workflow to close these is to switch to buffer and use :bdelete.

Suggested implementation: User can just call :CommandTBuffer, highlight the buffer he wants to close, press the shortcut key combination. It would save quite some time.

Comments

  1. Greg Hurrell 2011-09-05T20:37:44Z

    I actually think the right place for this kind of functionality is just a simple mapping in your ~/.vimrc. For example, this is what I have in mine for this purpose:

    map <leader>da :bufdo silent! bdelete<CR>

    I hit <leader>da (in my case, I have the comma key as my leader, so ,da); mnemonic: "delete all". This deletes all buffers, except those with unsaved changes. I just hit this if the buffer listing starts to become unmanageably large.

  2. Greg Hurrell 2011-09-05T20:39:00Z

    Going to mark this as closed. You're welcome to submit a patch if you'd like and I'll consider it.

  3. Greg Hurrell 2011-09-05T20:39:04Z

    Status changed:

    • From: new
    • To: closed
  4. anonymous 2011-09-07T16:10:29Z

    I tend to agree with the original poster and was looking for this functionality today... I would like to just highlight the buffer and press something like <C-d> and have that buffer gets closed. I don't want to just close all buffers like you suggest. Right now, I have to do a <C-t> to open in a new tab, then :bd to kill the buffer. Would be great if this were just one keystroke.

  5. DaveSanders 2011-09-13T19:20:39Z

    Howdy, I just about have this implemented, however, only having been using VIM for a week, I have an issue with it that I don't know how to fix:

    I have hooked it in so that you have a new option to "DeleteBuffer", which I have mapped via <C-d> After playing with it, it works great, but if you delete the last buffer, C-T wigs out because it can't close. (Which makes sense.) Also the screen gets unpredictable if you close a buffer that was the screen that you opened C-T on. (C-T jumps to the top of the screen.

    Playing with the code I can't figure out how to know if the buffer I'm deleting is in the current window that C-T popped up in. If I could figure that out then I could probably pop a :new in the place of the buffer I'm deleting.

    I tried putting in a :new before every buffer delete just to see what it would do, and unfortunately it made the :new really short and C-T still bounced to the top. So it needs to start a :new and then make it fill the space.

    I can try to pull together a patch of what I have so far (it's really minor) and maybe you could either handle the window issue with your expertise, or give me a hint on how to solve it myself? I'm at a loss because I don't know how to debug and see what variables are available in the ruby while its executing, so if you could give me an idea on that, I could probably figure it out...

    thanks for a great tool!

  6. urandom 2011-09-21T08:15:45Z

    Hi, the link is a patch that implements this feature. It seems to work, but I have absolutely no knowledge of ruby, so someone should look at it as well

    http://pastebin.com/gx41UaB3

  7. anonymous 2011-09-30T02:22:01Z

    Thank you Dave! Your patch is working great here.

  8. anonymous 2012-08-10T05:06:14Z

    Hey Wincent, Would you entertain a Git Pull Request for this feature? PS Thanks for command-t!

  9. Greg Hurrell 2012-08-11T18:52:42Z

    Sure.

Add a comment

Comments are now closed for this issue.

  • contact
  • legal

Menu

  • Blog
  • Wiki
  • Issues
  • Snippets