Show More
@@ -233,24 +233,24 b' For more information on filters and what you can do with the ``event`` object,' | |||||
233 | Enter to execute |
|
233 | Enter to execute | |
234 | ---------------- |
|
234 | ---------------- | |
235 |
|
235 | |||
236 | In the Terminal IPython shell – which by default use the ``prompt_toolkit`` |
|
236 | In the Terminal IPython shell – which by default uses the ``prompt_toolkit`` | |
237 |
interface, the semantic of pressing the :kbd:`Enter` key can be |
|
237 | interface, the semantic meaning of pressing the :kbd:`Enter` key can be | |
238 |
some case :kbd:`Enter` should execute code, and in others it |
|
238 | ambiguous. In some case :kbd:`Enter` should execute code, and in others it | |
239 |
line. IPython |
|
239 | should add a new line. IPython uses heuristics to decide whether to execute or | |
240 |
new line at cursor position. For example, if we detect that the current |
|
240 | insert a new line at cursor position. For example, if we detect that the current | |
241 |
not valid Python, then the user is likely editing code and the right |
|
241 | code is not valid Python, then the user is likely editing code and the right | |
242 |
to likely to insert a new line. If the current code is a simple |
|
242 | behavior is to likely to insert a new line. If the current code is a simple | |
243 |
`ord('*')`, then the right behavior is likely to execute. Though |
|
243 | statement like `ord('*')`, then the right behavior is likely to execute. Though | |
244 | desired semantics often varies from users to users. |
|
244 | the exact desired semantics often varies from users to users. | |
245 |
|
245 | |||
246 |
As the exact behavior of :kbd:`Enter` is |
|
246 | As the exact behavior of :kbd:`Enter` is is ambiguous, it has been special cased | |
247 |
|
|
247 | to allow users to completely configure the behavior they like. Hence you can | |
248 |
|
|
248 | have enter always execute code. If you prefer fancier behavior, you need to get | |
249 | behavior : start your coffee machine on even days of odd month. You'll have to |
|
249 | your hands dirty and read the ``prompt_toolkit`` and IPython documentation | |
250 | get your hands dirty and read prompt_toolkit and IPython documentation though. |
|
250 | though. See :ghpull:`10500`, set the | |
251 |
|
|
251 | ``c.TerminalInteractiveShell.handle_return`` option and get inspiration from the | |
252 |
|
|
252 | following example that insert new lines only after a pipe (``|``). Place the | |
253 |
|
|
253 | following in your configuration to do so:: | |
254 |
|
254 | |||
255 | def new_line_after_pipe(shell): |
|
255 | def new_line_after_pipe(shell): | |
256 | # shell is the same as get_ipython() |
|
256 | # shell is the same as get_ipython() |
General Comments 0
You need to be logged in to leave comments.
Login now