zefei / vim-wintabs

Modern buffer manager for Vim
MIT License
325 stars 25 forks source link

[Feature Request/Discussion] Use fzf for selecting an open buffer #44

Closed dylan-chong closed 5 years ago

dylan-chong commented 5 years ago

Note : this is just a discussion with some thoughts, I'm not sure what I am proposing exactly the best solution that is possible.

Problem

What I'm trying to do is, what I have a lot of Vim tabs and buffers and each tab open, I would like to jump to an existing buffer by typing in the file name (hopefully in a fuzzy way for speed).

Potential solution

Have some way of listing the buffers opened by win tabs, so that they can be sent into a fzf window. The user can then use fzf to fuzzy search for the open buffer. When the user presses enter, Vim would then jump to the existing open buffer, without creating a new one.

Other notes

I'm thinking that it is possible this use case is very specific to my own workflow, and may not be useful for anyone else. Or maybe this could be made more general to suit a greater range of use cases provide greater number of people.

What are everyone's thoughts on this?

zefei commented 5 years ago

This was suggested in #21. I decided not to put a specialized API for fzf because I thought using fzf :History together with g:wintabs_switchbuf is good enough for such use cases. But I'd like to hear your thoughts or others' as well if having an fzf command would be much better for your workflow.

dylan-chong commented 5 years ago

Aha! switchbuf is exactly what I was looking for!

FZF has a :Buffers command which lists open buffers. This seems to work perfectly: it lists all of the buffers open in wintabs, and combine with the switchbuf option, Vim jumps to the correct tab/window when pressing enter inside FZF buffers :Buffers.

I think this solves the problem perfectly