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

Goto buffer by num #8198

Closed

Conversation

DreckSallow
Copy link

@DreckSallow DreckSallow commented Sep 7, 2023

Implement the select buffer by index :

  • Command: :buffer-index <number>
  • Alias: :bi <number>
  • Command: :buffer-first
  • Command: :buffer-last

@tmke8
Copy link

tmke8 commented Sep 7, 2023

Thanks for implementing this! It looks to me like :buffer-index 9 brings you to the last buffer but I think that might be better handled with a separate command like :buffer-last (and there could also be :buffer-first though that is of course equivalent to : buffer-index 1). Then people can map whatever keys they want to :buffer-last.

And I think it would be okay if :buffer-index also worked with higher numbers? Like, :buffer-index 56. Not sure what exactly the use case would be but there might be one.

@gabydd
Copy link
Member

gabydd commented Sep 7, 2023

I think for larger numbers we could just min it with the amount of buffers and then any higher number would just bring you to the last one, then we don't have to special case 9 you can just use something like 999 to go to the last buffer. Also mentioning this pr: #4756 so they are linked

@DreckSallow
Copy link
Author

I wanted to apply the same behavior of Chrome and Firefox tabs. But I think your approaches are good.
Now you can:

  • Access the first buffer using :buffer-first or :bf
  • Access the last buffer using :buffer-last or :bl
  • Access any buffer by its index with :buffer-index <n> or :bi <n> . If the index exceeds the number of buffers, it will automatically switch to the last buffer.

@tmke8
Copy link

tmke8 commented Sep 22, 2023

I wanted to try this out with this key mapping:

[keys.normal.space]
1 = ":buffer-index 1"
2 = ":buffer-index 2"
3 = ":buffer-index 3"
4 = ":buffer-index 4"
5 = ":buffer-index 5"
6 = ":buffer-index 6"
7 = ":buffer-index 7"
8 = ":buffer-index 8"
9 = ":buffer-index 9"
0 = ":buffer-index 10"

but I realized this doesn't work at the moment because of this issue:

(Only 0 can currently be mapped.)

Nevertheless, I think this is a good PR!

@tmke8
Copy link

tmke8 commented Feb 14, 2024

#8471 has been merged, so it should now be possible to use space = {1 = ":buffer-index 1"} as a mapping.

@pascalkuthe
Copy link
Member

I don't think we will be going forward with this one. The bufferline and the "gui like ordered tabs" workflow is not a priorty. We focus on picker baswd navigation instead.

The current buffer ordering is an implementation detail and I would like to not make users rely on it with commands or introsuce somekind of manual order (buffer picker is sorted by most recently used by contrast which I much prefer).

Sorry we didn't give you that kind of feedback sooner. Thank you for contributing!

@tmke8
Copy link

tmke8 commented Apr 12, 2024

I don't think anyone expects the order to be fixed, but the current internal order is always visible in the bufferline, so I don't see the problem there. (If the order in the bufferline changes after, e.g., opening a new buffer, that seems completely fine.)

I don't think you realize just how much of a mental overhead there is for using a buffer picker if you've never had it set up such that you can switch buffers at the blink of an eye. You can set it up in (n)vim that the buffers are shown in a bufferline and numbered – you then only need the barest glance at the bufferline and then you type space+num, or whatever your shortcut is, and you're immediately there. You never leave your editing flow. A buffer picker on the other hand, requires some kind of context change in your brain: a new menu appears mid-screen, you have to parse what it says, you have to find the buffer you're looking for, you have to type potentially multiple letters to select the right one.

As someone used to a numbered bufferline with quick switching, I can tell you the buffer picker workflow feels very cumbersome every time I have to use it.

@obedm503
Copy link

The buffer picker is exactly the issue because it changes so much as you work through multiple files. Being able to jump around without reading or typing the buffer name saves time and maintains focus.

Right now I open the files I'll work on in some specific order (there's no way to order the bufferline manually) and g-n/g-p my way around. The buffer picker sorted by recency is impractical.

@markstos
Copy link
Contributor

@obedm503 On PR #8875 I proposed that the "amp-like" jumping to other locations should extended other windows: #8875 (comment)

If implemented, it would also directly jumping to other buffers, at the ones that have some of their content or name visible.

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

Successfully merging this pull request may close these issues.

6 participants