def edit_text(text, prompt="Edit text"):
    fname = os.path.join(os.environ["HOME"], ".edit_text.txt")
    fo = open(fname, "w")
    fo.write(prompt + ":\n")
    fo.write(text)
    fo.close()
    os.system('%s "%s"' % (os.environ.get("EDITOR", "/usr/bin/vim"), fname))
    fo = open(fname, "r")
    try:
        text = fo.read()
    finally:
        fo.close()
        os.unlink(fname)
    return text[text.find("\n")+1:]
Run $EDITOR on text. Defaults to vim.
dataset/ETHPy150Open kdart/pycopia/core/pycopia/cliutils.py/edit_text