Search code examples
autocompleteocamlutop

Autocompletion in utop


I am sorry for the newb question, but I am just starting with OCaml and I could not find how to ues utop autocompletion.

When I start typing something in utop, I see a list of choices at the bottom of the shell. If there is only one valid choice, pressing TAB will autocomplete what I am writing. But if there are multiple valid choices, and I spot the one I want, I have not found a way to select it (other than keep writing).

For instance (assuming I have imported Core.Std) I type

Float.of

The first suggestion is Float.of_float, the second one is Float.of_int. How do I select the second one?


Solution

  • To quote utop's README:

    utop display a bar after the prompt which is used to show possible completions in real-time. You can navigate in it using M-left and M-right, and select one completion using M-tab. The M denotes the meta key, which is Alt most of the time.

    So, you can navigate through completions using Alt.

    Have fun with utop!

    EDIT:

    It seems Alt doesn't always work, depending on the terminal. Typing Esc then the good keys, however, works.

    Also, the bindings can be easily rebinded through a ~/.lambda-term-inputrc file, see here.