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

Simplistic key mapping support #163

Closed
junegunn opened this Issue Mar 27, 2015 · 13 comments

Comments

Projects
None yet
2 participants
@junegunn
Copy link
Owner

junegunn commented Mar 27, 2015

There has been demands for custom key mappings inside fzf (#139, #96, #61) mostly for better integration with Vim. So here's a simple idea that might meet such requirements.

Let's say we add an option that takes a comma-separated list of key chords, such as ctrl-v, ctrl-t, or alt-a. I can't think of a good name for this imaginary option, but let's call it --select-with for now.

fzf --select-with=ctrl-v,alt-s

Then fzf will allow me to select the item with any of the given key chords in addition to the default enter key. But in this case, fzf will print the name of the key chord used as the first line of the output.

> fzf --select-with=ctrl-v,alt-s
alt-s
foobar

Now we know which key was pressed, and our script can use the information to decide what to do next.

There are some questions to be answered:

  1. What should be the name of the option?
    • --select-with
    • --select-key
    • --selector
    • --expect
    • --using
    • --with
    • --via
    • --on
  2. Should we allow enter key by default? Or should we demand that the user specify enter key (or ctrl-m) as well? (e.g. --select-with=alt-t,enter)
    • I don't think it makes a lot of sense to disable enter key
  3. When this option is used with --print-query, which should be printed first, query or the key pressed?
    • You type in the query, then press the key chord, so query should be printed first
@junegunn

This comment has been minimized.

Copy link
Owner Author

junegunn commented Mar 28, 2015

Added --expect option in 0.9.6.

@junegunn junegunn closed this Mar 28, 2015

@Tranquility

This comment has been minimized.

Copy link

Tranquility commented Mar 28, 2015

I updated to 0.9.6 but get unknown option: --expect. The vim plugin also fails.

@junegunn

This comment has been minimized.

Copy link
Owner Author

junegunn commented Mar 28, 2015

@Tranquility Did you rerun the install script? It'll download the new binary.

@junegunn

This comment has been minimized.

Copy link
Owner Author

junegunn commented Mar 28, 2015

Hmm, maybe I should check if the version is >= 0.9.6 from inside vim plugin.

@Tranquility

This comment has been minimized.

Copy link

Tranquility commented Mar 28, 2015

fzf --version tells me that I am at 0.9.6.

@junegunn

This comment has been minimized.

Copy link
Owner Author

junegunn commented Mar 28, 2015

@Tranquility What's the output of :!fzf --version from inside vim?

@Tranquility

This comment has been minimized.

Copy link

Tranquility commented Mar 28, 2015

It is not related to vim. Version 0.9.6 does not contain the option, even fzf --help does not list it.

@junegunn

This comment has been minimized.

Copy link
Owner Author

junegunn commented Mar 28, 2015

That's super strange. I have tested it both on OS X and Linux. Can you show me the md5 hash of the binary installed?

@Tranquility

This comment has been minimized.

Copy link

Tranquility commented Mar 28, 2015

Oh, I am sorry, I found the problem. I built it from source yesterday. So the version from by $GOPATH was used which already had the new version number. After I removed the file it uses the correct binary.

@junegunn

This comment has been minimized.

Copy link
Owner Author

junegunn commented Mar 28, 2015

Ah, I see. No problem :) Try CTRL-T/X/V from :FZF command.

@Tranquility

This comment has been minimized.

Copy link

Tranquility commented Mar 28, 2015

It's awesome!

@junegunn

This comment has been minimized.

Copy link
Owner Author

junegunn commented Mar 28, 2015

Cool, thanks!

@junegunn

This comment has been minimized.

Copy link
Owner Author

junegunn commented Mar 29, 2015

FYI, there was a bug in the new vim plugin 😔 (#167) Please update again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment