Fzf: What does --toggle-sort do?

Created on 27 Nov 2016  路  4Comments  路  Source: junegunn/fzf

  • Category

    • [ ] fzf binary

    • [ ] fzf-tmux script

    • [x] Key bindings

    • [ ] Completion

    • [ ] Vim

    • [ ] Neovim

    • [ ] Etc.

  • OS

    • [x] Linux

    • [ ] Mac OS X

    • [ ] Windows

    • [ ] Windows Subsystem for Linux

    • [ ] Etc.

  • Shell

    • [x] bash

    • [ ] zsh

    • [ ] fish

Hi, --toggle-sort is being used in fzf_history but fzf --help doesn't mention what it does.

In fzf_history, why have +s followed by --toggle-sort?

Also, can you please explain what -n does with an example?

question

Most helpful comment

Each comma-separated search scope is tried in order. So fzf first checks if the query matches in 2.. scope, if not, then it searches the whole scope ...

  • ^sudo won't match without 2..
  • 2su won't match without ..
  • ^20 is also valid

See the point?

As you can see the order of the command history hasn't changed.

Try it after typing in some query string. Regarding the ranking algorithm, see https://github.com/junegunn/fzf/blob/0.15.9/src/algo/algo.go#L39

All 4 comments

Have you looked at man fzf? More information can be found in the man page. --toggle-sort is kind of deprecated (no plan to remove it though) as it's equivalent to --bind KEYNAME:toggle-sort. We disable sorting with +s (--no-sort) by default to display the commands in chronological order. But sorting can be dynamically enabled by the key specified in --toggle-sort.

-n 2.. (ignoring index number) allows you to perform prefix match on the command for example ^git.

Have you looked at man fzf?

No, I didn't even know a man page existed. Thanks for letting me know. That helps but just raises more questions for eg. this bit here: -n2..,... The man page says -n2.. will restrict the search scope to the 2nd to the last field but then there's also ,.. after that increasing the search scope to all fields. Either I'm not following what it does exactly or that seems redundant.

Also, the only thing in there is this line toggle-sort is equivalent to --toggle-sort. It doesn't mention how sorting works. I tried using C-r but that doesn't seem to do anything. Here's an example of the before and after pressing it:

Before:
before-1

After:
after-1

As you can see the order of the command history hasn't changed.

Each comma-separated search scope is tried in order. So fzf first checks if the query matches in 2.. scope, if not, then it searches the whole scope ...

  • ^sudo won't match without 2..
  • 2su won't match without ..
  • ^20 is also valid

See the point?

As you can see the order of the command history hasn't changed.

Try it after typing in some query string. Regarding the ranking algorithm, see https://github.com/junegunn/fzf/blob/0.15.9/src/algo/algo.go#L39

Ah, I see. Thanks a lot for answering all my questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olethanh picture olethanh  路  3Comments

skamsie picture skamsie  路  3Comments

firedev picture firedev  路  3Comments

fenuks picture fenuks  路  3Comments

erusev picture erusev  路  3Comments