Skip to main content

🖋 Open the default text editor 🖋

Project description

🖋 editor - Open a text editor 🖋

editor opens the default text editor or your favorite editor to edit an existing file, a new file, or a tempfile, blocks while the user edits text, then returns the contents of the file.

You can pass a parameter editor= to specify an editor or leave it empty, in which case the editor is:

  • The contents of the environment variable VISUAL, if it's set, otherwise:
  • The the contents of the environment variable EDITOR, if it's set, otherwise:
  • The string 'Notepad', if the code is running on Windows, otherwise:
  • The string 'vim'

Example 1: Using a temporary file

If no filename is provided, a temporary file gets edited, and its contents returned.

import editor

comments = editor.editor(text='Comments here\n\n')
# Pop up the default editor with a tempfile containing "Comments here",
# then return the contents and delete the tempfile.

Example 2: Using a named file

If a filename is provided, then that file gets edited.

import os

FILE = 'file.txt'
assert not os.path.exists(FILE)

comments = editor.editor(text=MESSAGE, filename=FILE)
# Pop up an editor for a new FILE containing MESSAGE, user edits
# This file is saved when the user exits the editor.

assert os.path.exists(FILE)

# You can edit an existing file too, and select your own editor.
comments2 = editor.editor(filename=FILE, editor='emacs -nw')

API Documentation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

editor-1.8.0.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

editor-1.8.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file editor-1.8.0.tar.gz.

File metadata

  • Download URL: editor-1.8.0.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for editor-1.8.0.tar.gz
Algorithm Hash digest
SHA256 b07e1bbcb8b33f05c2e6ed3ce77ee9756354ada840a18aad7c0536d967fe4c0b
MD5 24de1a355222c3365b9366dec4ae118e
BLAKE2b-256 ae5ffe06c2a13a5282dcef4c7133bb348d4125a9aa69c5fb49037a004599d73a

See more details on using hashes here.

File details

Details for the file editor-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: editor-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for editor-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d47ff88ae6c5f6c43d28c30b6f7fd59a24741175a1771ab06c969d946d7dfd0
MD5 fc1afff6cb0ab7771c4caeee807ac2f8
BLAKE2b-256 55b86648cadf38b61045262bf2a534e526f04eb833275ad1fc77a2026e9f7e3a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page