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