Development version
This document describes in-flight development work.
Warning
Please do not edit this file by hand (doing so will likely cause merge conflicts for other Pull Requests). Instead, create a new file in the docs/source/whatsnew/pr folder
Released .... ...., 2019
Need to be updated:
Autosuggestion is a very useful feature available in fish, zsh, and prompt-toolkit.
Ptpython allows users to enable this feature in ptpython/config.py.
This feature allows users to accept autosuggestions with ctrl e, ctrl f, or right arrow as described below.
- Start ipython
![../_images/auto_suggest_prompt_no_text.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_prompt_no_text.png)
- Run print("hello")
![../_images/auto_suggest_print_hello_suggest.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_print_hello_suggest.png)
- Press p to see the autosuggestion
![../_images/auto_suggest_print_hello_suggest.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_print_hello_suggest.png)
- Press ctrl f, or ctrl e, or right arrow to accept the suggestion
![../_images/auto_suggest_print_hello.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_print_hello.png)
You can also complete word by word:
- Run def say_hello(): print("hello")
![../_images/auto_suggest_second_prompt.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_second_prompt.png)
- Press d to see the autosuggestion
![../_images/audo_suggest_d_phantom.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/audo_suggest_d_phantom.png)
- Press alt f to accept the first word of the suggestion
![../_images/auto_suggest_def_phantom.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_def_phantom.png)
Importantly, this feature does not interfere with tab completion:
- After running def say_hello(): print("hello"), press d
![../_images/audo_suggest_d_phantom.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/audo_suggest_d_phantom.png)
- Press Tab to start tab completion
![../_images/auto_suggest_d_completions.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_d_completions.png)
3A. Press Tab again to select the first option
![../_images/auto_suggest_def_completions.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_def_completions.png)
3B. Press alt f to accept to accept the first word of the suggestion
![../_images/auto_suggest_def_phantom.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_def_phantom.png)
3C. Press ctrl f or ctrl e to accept the entire suggestion
![../_images/auto_suggest_match_parens.png](/upstream/ipython/raw/2b87e1eba3769e2c2f782dafa394e29682b1c1a5/docs/source/_images/auto_suggest_match_parens.png)
To install a version of ipython with autosuggestions enabled, run:
pip install git+https://github.com/mskar/ipython@auto_suggest
Currently, autosuggestions are only shown in the emacs or vi insert editing modes:
- The ctrl e, ctrl f, and alt f shortcuts work by default in emacs mode.
- To use these shortcuts in vi insert mode, you will have to create custom keybindings in your config.py.
As a reminder, IPython master has diverged from the 7.x branch, thus master may have more feature and API changes.