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

Enhance filter and find commands #2556

Open
sxyazi opened this issue Mar 31, 2025 · 1 comment
Open

Enhance filter and find commands #2556

sxyazi opened this issue Mar 31, 2025 · 1 comment
Labels
feature New feature request

Comments

@sxyazi
Copy link
Owner

sxyazi commented Mar 31, 2025

1. New --then option for the filter command

This issue proposes adding a new optional filter --then option that performs an extra action after the user has finished entering filter keywords and confirms by pressing <Enter>.

This helps reduce one or two extra keystrokes (depending on the value of --then), thereby improving efficiency and increasing QoL.

Since Yazi's filter feature is interactive and provides real-time feedback based on the user's keywords, users already have a basic expectation for the filter results when they press <Enter>, making this option even more meaningful.

Available values:

  • select: Select all filter results, which saves a <C-a> keystroke for selecting all.
  • select-back: Select all filter results and exit the filter view, which saves both <C-a> and <Esc> keystrokes.
  • deselect: Deselect all filter results, which saves <C-a> and <C-r> keystrokes (by selecting all first and then inverting the selection).
  • deselect-back: Deselect all filter results and exit the filter view, which saves the keystrokes for <C-a>, <C-r>, and <Esc>.
  • toggle: Toggle the selection state of all filter results, which saves a <C-r> keystroke.
  • toggle-back: Toggle the selection state of all filter results and exit the filter view, which saves <C-r> and <Esc> keystrokes.

Accordingly, a new default key binding F will be added for filter --then=select-back.

2. Interoperability between the filter and find commands

This issue also proposes making the filter and find commands interoperable.

Specifically, the filter keywords entered by the user should be reusable by find, which makes the following workflow possible:

  • Press F to start filter --then=select-back.
  • Type keywords and press <Enter>, the filter results that match the keywords are selected and the filter view is exited.
  • Now, the user can click n or N to use the previous "filter" keywords to "find" and navigate back and forth between (selected) files in the list.
@sxyazi sxyazi added feature New feature request needs info and removed needs info labels Mar 31, 2025
@sxyazi sxyazi changed the title Enhance filter command Enhance filter and find commands Mar 31, 2025
@csswright
Copy link

Nice, though I find repeated filtering workflow (#2385) to be strictly better than find because of the instant feedback (even as a vim user where n and N is natural). With n and N you are still jumping through entries in a semi-filtered list, but with repeated filtering + instant feedback the intended set of files can be arrived quicker.

Besides keystrokes, there's effort and cognitive overhead to consider. Repeated filtering just involves typing substrings with instant feedback (substrings don't need to be long--bigram/trigrams are enough, like with fzf), whereas n and N typically requires an already filtered list to be effective and also tapping these keys a precise number of times to get to the intended item, unless you know ahead of time the string you're looking for is already fairly unique in the list to reduce spamming n/N. The ergonomics of typing familiar sequences of bigrams/trigrams/substrings keep you in the flow and repeated narrowing for instant feedback provide additional context to what you're searching for.

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

No branches or pull requests

2 participants