MCPcopy Index your code
hub / github.com/ipython/ipython / edit

Method edit

IPython/core/magics/code.py:548–757  ·  view source on GitHub ↗

Bring up an editor and execute the resulting code. Usage: %edit [options] [args] %edit runs IPython's editor hook. The default version of this hook is set to call the editor specified by your $EDITOR environment variable. If this isn't found, it will defau

(self, parameter_s='',last_call=['',''])

Source from the content-addressed store, hash-verified

546 @skip_doctest
547 @line_magic
548 def edit(self, parameter_s='',last_call=['','']):
549 """Bring up an editor and execute the resulting code.
550
551 Usage:
552 %edit [options] [args]
553
554 %edit runs IPython's editor hook. The default version of this hook is
555 set to call the editor specified by your $EDITOR environment variable.
556 If this isn't found, it will default to vi under Linux/Unix and to
557 notepad under Windows. See the end of this docstring for how to change
558 the editor hook.
559
560 You can also set the value of this editor via the
561 ``TerminalInteractiveShell.editor`` option in your configuration file.
562 This is useful if you wish to use a different editor from your typical
563 default with IPython (and for Windows users who typically don't set
564 environment variables).
565
566 This command allows you to conveniently edit multi-line code right in
567 your IPython session.
568
569 If called without arguments, %edit opens up an empty editor with a
570 temporary file and will execute the contents of this file when you
571 close it (don't forget to save it!).
572
573
574 Options:
575
576 -n <number>: open the editor at a specified line number. By default,
577 the IPython editor hook uses the unix syntax 'editor +N filename', but
578 you can configure this by providing your own modified hook if your
579 favorite editor supports line-number specifications with a different
580 syntax.
581
582 -p: this will call the editor with the same data as the previous time
583 it was used, regardless of how long ago (in your current session) it
584 was.
585
586 -r: use 'raw' input. This option only applies to input taken from the
587 user's history. By default, the 'processed&#x27; history is used, so that
588 magics are loaded in their transformed version to valid Python. If
589 this option is given, the raw input as typed as the command line is
590 used instead. When you exit the editor, it will be executed by
591 IPython&#x27;s own processor.
592
593 -x: do not execute the edited code immediately upon exit. This is
594 mainly useful if you are editing programs which need to be called with
595 command line arguments, which you can then do using %run.
596
597
598 Arguments:
599
600 If arguments are given, the following possibilities exist:
601
602 - If the argument is a filename, IPython will load that into the
603 editor. It will execute its contents with execfile() when you exit,
604 loading any code in the file into your interactive namespace.
605

Callers

nothing calls this directly

Calls 9

_find_edit_targetMethod · 0.95
_edit_macroMethod · 0.95
preserve_keysClass · 0.90
parse_optionsMethod · 0.80
safe_execfileMethod · 0.80
addMethod · 0.45
flushMethod · 0.45
run_cellMethod · 0.45
showtracebackMethod · 0.45

Tested by

no test coverage detected