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 request: Ctrl+F to complete one character at a time #4984

Closed
mrcnski opened this issue May 14, 2018 · 12 comments · Fixed by #7217
Closed

Feature request: Ctrl+F to complete one character at a time #4984

mrcnski opened this issue May 14, 2018 · 12 comments · Fixed by #7217

Comments

@mrcnski
Copy link

mrcnski commented May 14, 2018

Hi, thanks for Fish. Love it.

Let's say I start typing out fish -- and the completion for fish --version pops up. If I press Ctrl+E, the entire line is completed. Pressing Ctrl+F does the same thing. I was wondering if we couldn't make Ctrl+F do something different: complete one character at a time.

For another example, if I type out cargo the completion appears for cargo test --features="use-mock-routing" -- --nocapture. Well, sometimes I just want the cargo test or cargo test --features part, so completion character-by-character would be useful to have. It also would be consistent with Ctrl+E going to end of line and Ctrl+F going one character forward in many editors.

I think this would be an easy change to make the "friendly interactive shell" a tiny bit friendlier :)

@mqudsi
Copy link
Contributor

mqudsi commented May 14, 2018

Doesn't right arrow already do that? And alt+right completes a single word. You could just add a binding?

@mrcnski
Copy link
Author

mrcnski commented May 14, 2018

Doesn't right arrow already do that?

No, it apparently has the same behavior as Ctrl+E. I also would like to avoid using the arrow keys as I don't generally take my hands off the home row.

And alt+right completes a single word.

So it does. Is there an alternative that doesn't use an arrow key? This would actually be useful for me, as would character-wise completion in some circumstances.

You could just add a binding?

Ah I'll read up on that when I have time, thanks for the response :)

@mqudsi
Copy link
Contributor

mqudsi commented May 14, 2018

Yeah, bindings should address your concerns. They're really easy to use, too :)

@zanchey zanchey added this to the fish-future milestone May 15, 2018
@zanchey
Copy link
Member

zanchey commented May 15, 2018

forward-char always accepts the full autosuggestion, though, so there's definitely an enhancement possibility here.

@cskrisz
Copy link

cskrisz commented Jul 26, 2018

Is there an alternative that doesn't use an arrow key?

You can use emacs shortcuts, e.g. Alt+F for completing one word.

@mrcnski
Copy link
Author

mrcnski commented Jul 27, 2018

@cskrisz That inserts a little ƒ symbol for me, in Iterm2 at least. I would love to have fully featured Emacs-style completion/navigation though :)

@cskrisz
Copy link

cskrisz commented Jul 31, 2018

@m-cat For iTerm2, in Preferences > Profiles > Keys you can set the option key to Esc+ to use it as Meta. You can set the left and right key separately so you can still type special characters if you want.

@mrcnski
Copy link
Author

mrcnski commented Jul 31, 2018

@cskrisz Cool beans -- thanks!

You can set the left and right key separately so you can still type special characters if you want.

Hmm, don't think I ever needed to type a special character in the terminal :)

@rien333
Copy link

rien333 commented Jan 11, 2019

Yes, this is fairly annoying and feels inconsistent given that forward-word does not complete the full suggestion. There is enough bindings to complete the autosuggestion as is (ctrl+e, right key). Would altering the ctrl+f behaviour be better as a variable, or should ctrl+f by default only perform forward char operations?

You could just add a binding. #4984 (comment)

How would the binding look like?

@PoignardAzur
Copy link
Contributor

Adding my support to this feature request. I already use the End key when I want to complete to the end of a prompt; being able to complete only one character would be convenient (right now I end up auto-completing a single word with ctrl+right, then backspacing to the character I wanted).

krobelus pushed a commit that referenced this issue Aug 1, 2020
This allows users to add custom keybindings to autocomplete only one
character at a time.

Resolves #4984
@PoignardAzur
Copy link
Contributor

Adding a summary for posterity:

There is no default keybinding to complete a single character at the time. However, you can create your own binding by typing the following command in the shell:

bind \cf forward-single-char     # Complete a single char when pressing Ctrl+F

or:

bind \e\[C forward-single-char   # Complete a single char when pressing right arrow

To get you desired keybinding in every session, add one of the above lines to your ~/.config/fish/config.fish file.

@mrcnski
Copy link
Author

mrcnski commented Aug 1, 2020

Nice, thank you very much for your efforts. It is unfortunate that the solution will not be the default -- "this breaks existing behavior" is a bad argument for not fixing behavior that is obviously faulty. This change is an obvious improvement, and if the right people had chimed in on your contribution, this would have been the default. It's too bad I wasn't aware of that PR.

@zanchey zanchey modified the milestones: fish-future, fish 3.2.0 Aug 2, 2020
andreiborisov pushed a commit to andreiborisov/dash-fish that referenced this issue Aug 13, 2020
This allows users to add custom keybindings to autocomplete only one
character at a time.

Resolves fish-shell/fish-shell#4984
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants