Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Open file while retaining focus / Preview files #28

Open
jeetsukumaran opened this issue Mar 25, 2022 · 5 comments
Open

Feature: Open file while retaining focus / Preview files #28

jeetsukumaran opened this issue Mar 25, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@jeetsukumaran
Copy link

(1) I would like to open Dirbuf, find a file, open it in a new vertical split, and close Dirbuf (restoring the previous buffer that was in the window that Dirbuf was rendered in).

In other words, I would like Dirbuf to open a file in a new split, restore the previous buffer that was in its own window, and then delete itself.

If I try require('dirbuf').enter('vsplit'), it does this, but then leaves Dirbuf in open in the original window. I then have to navigate back to the original window and either hit <C-O> or quit it myself. If I accidentally hit :bwipe, then I lose the split that I wanted open (had the buffer view that I was using before I launched dirbuf).

(2) Extension of this: I would like to select a file in Dirbuf, and open it in a new split (vertical or otherwise) in the background (i.e., not just keeping Dirbuf open, but also retaining focus on Dirbuf.

@elihunter173
Copy link
Owner

(2) Extension of this: I would like to select a file in Dirbuf, and open it in a new split (vertical or otherwise) in the background (i.e., not just keeping Dirbuf open, but also retaining focus on Dirbuf.

I've wanted something somewhat like this before for easily previewing files. I can easily see a feature serving both this open but keep focus use case and file previews. I'll have to look at how vim-vinegar and vim-dirvish implement previewing to see how to fit this into Dirbuf

For (1), I normally split and then open Dirbuf in the place of the new split rather than opening Dirbuf and then splitting. But, if (2) is implemented then it should be fairly easy to make a custom mapping or command that does exactly this.

@elihunter173 elihunter173 changed the title How to Open Buffers in New Splits Feature: Open file while retaining focus / Preview files Mar 26, 2022
@elihunter173 elihunter173 added the enhancement New feature or request label Mar 26, 2022
@elihunter173
Copy link
Owner

I hope you don't mind me changing the issue name. Just trying to organize it in terms of what should be implemented

@jeetsukumaran
Copy link
Author

I hope you don't mind me changing the issue name. Just trying to organize it in terms of what should be implemented

No worries! :)

@jeetsukumaran
Copy link
Author

For (1), I normally split and then open Dirbuf in the place of the new split rather than opening Dirbuf and then splitting.

As I noted in #22 (comment), this is exactly what I do some of the time. BUT:

... But other times, I find this awkward:
- it adds an split to a view that makes all the other splits smaller and itself is small; maybe this not a problem at times . But sometimes the reduced split size is a pain
- when leaving Dirbuf without choosing anything, I now have an extra split that I have to close

@elihunter173
Copy link
Owner

So previewing actually works today if you use require("dirbuf").enter("pedit"). However, that opens it in Vim's actual :help preview-window, which I don't think many people expect. It's certainly not what vim-dirvish does...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants