def find_editor ( ) -> str : editor = os . environ . get ( 'EDITOR' ) if not editor : if sys . platform [ : 3 ] == 'win' : editor = 'notepad' else : # Favor command-line editors first so we don't leave the terminal to edit for editor in [ 'vim' , 'vi' , 'emacs' , 'nano' , 'pico' , 'gedit' , 'kate' , 'subl' , 'geany' , 'atom' ] : if which ( editor ) : break return editor
set default editorfor python scripts windows
Find a reasonable editor to use by default for the system that the cmd2 application is running on .
def find_editor() -> str:
    """Find a reasonable editor to use by default for the system that the cmd2 application is running on."""
    editor = os.environ.get('EDITOR')
    if not editor:
        if sys.platform[:3] == 'win':
            editor = 'notepad'
        else:
            # Favor command-line editors first so we don't leave the terminal to edit
            for editor in ['vim', 'vi', 'emacs', 'nano', 'pico', 'gedit', 'kate', 'subl', 'geany', 'atom']:
                if which(editor):
                    break
    return editor