Show More
@@ -24,6 +24,75 b' Need to be updated:' | |||||
24 |
|
24 | |||
25 |
|
25 | |||
26 |
|
26 | |||
|
27 | Autosuggestion is a very useful feature available in `fish <https://fishshell.com/>`__, `zsh <https://en.wikipedia.org/wiki/Z_shell>`__, and `prompt-toolkit <https://python-prompt-toolkit.readthedocs.io/en/master/pages/asking_for_input.html#auto-suggestion>`__. | |||
|
28 | ||||
|
29 | `Ptpython <https://github.com/prompt-toolkit/ptpython#ptpython>`__ allows users to enable this feature in | |||
|
30 | `ptpython/config.py <https://github.com/prompt-toolkit/ptpython/blob/master/examples/ptpython_config/config.py#L90>`__. | |||
|
31 | ||||
|
32 | This feature allows users to accept autosuggestions with ctrl e, ctrl f, | |||
|
33 | or right arrow as described below. | |||
|
34 | ||||
|
35 | 1. Start ipython | |||
|
36 | ||||
|
37 | .. image:: ../_images/auto_suggest_prompt_no_text.png | |||
|
38 | ||||
|
39 | 2. Run ``print("hello")`` | |||
|
40 | ||||
|
41 | .. image:: ../_images/auto_suggest_print_hello_suggest.png | |||
|
42 | ||||
|
43 | 3. Press p to see the autosuggestion | |||
|
44 | ||||
|
45 | .. image:: ../_images/auto_suggest_print_hello_suggest.png | |||
|
46 | ||||
|
47 | 4. Press ctrl f, or ctrl e, or right arrow to accept the suggestion | |||
|
48 | ||||
|
49 | .. image:: ../_images/auto_suggest_print_hello.png | |||
|
50 | ||||
|
51 | You can also complete word by word: | |||
|
52 | ||||
|
53 | 1. Run ``def say_hello(): print("hello")`` | |||
|
54 | ||||
|
55 | .. image:: ../_images/auto_suggest_second_prompt.png | |||
|
56 | ||||
|
57 | 2. Press d to see the autosuggestion | |||
|
58 | ||||
|
59 | .. image:: ../_images/audo_suggest_d_phantom.png | |||
|
60 | ||||
|
61 | 3. Press alt f to accept the first word of the suggestion | |||
|
62 | ||||
|
63 | .. image:: ../_images/auto_suggest_def_phantom.png | |||
|
64 | ||||
|
65 | Importantly, this feature does not interfere with tab completion: | |||
|
66 | ||||
|
67 | 1. After running ``def say_hello(): print("hello")``, press d | |||
|
68 | ||||
|
69 | .. image:: ../_images/audo_suggest_d_phantom.png | |||
|
70 | ||||
|
71 | 2. Press Tab to start tab completion | |||
|
72 | ||||
|
73 | .. image:: ../_images/auto_suggest_d_completions.png | |||
|
74 | ||||
|
75 | 3A. Press Tab again to select the first option | |||
|
76 | ||||
|
77 | .. image:: ../_images/auto_suggest_def_completions.png | |||
|
78 | ||||
|
79 | 3B. Press alt f to accept to accept the first word of the suggestion | |||
|
80 | ||||
|
81 | .. image:: ../_images/auto_suggest_def_phantom.png | |||
|
82 | ||||
|
83 | 3C. Press ctrl f or ctrl e to accept the entire suggestion | |||
|
84 | ||||
|
85 | .. image:: ../_images/auto_suggest_match_parens.png | |||
|
86 | ||||
|
87 | To install a version of ipython with autosuggestions enabled, run: | |||
|
88 | ||||
|
89 | ``pip install git+https://github.com/mskar/ipython@auto_suggest`` | |||
|
90 | ||||
|
91 | Currently, autosuggestions are only shown in the emacs or vi insert editing modes: | |||
|
92 | ||||
|
93 | - The ctrl e, ctrl f, and alt f shortcuts work by default in emacs mode. | |||
|
94 | - To use these shortcuts in vi insert mode, you will have to create `custom keybindings in your config.py <https://github.com/mskar/setup/commit/2892fcee46f9f80ef7788f0749edc99daccc52f4/>`__. | |||
|
95 | ||||
27 | .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT. |
|
96 | .. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT. | |
28 |
|
97 | |||
29 | As a reminder, IPython master has diverged from the 7.x branch, thus master may |
|
98 | As a reminder, IPython master has diverged from the 7.x branch, thus master may |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now