🖋 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
Release history Release notifications | RSS feed
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.6.6.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file editor-1.6.6.tar.gz
.
File metadata
- Download URL: editor-1.6.6.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.11 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb6989e872638cd119db9a4fce284cd8e13c553886a1c044c6b8d8a160c871f8 |
|
MD5 | fec51cb0883f9ff5b8cc3771dbb57393 |
|
BLAKE2b-256 | 2a92734a4ab345914259cb6146fd36512608ea42be16195375c379046f33283d |
File details
Details for the file editor-1.6.6-py3-none-any.whl
.
File metadata
- Download URL: editor-1.6.6-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.11 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e818e6913f26c2a81eadef503a2741d7cca7f235d20e217274a009ecd5a74abf |
|
MD5 | 2d1d6902051b5c88172d059d1f974cb5 |
|
BLAKE2b-256 | 1bc24bc8cd09b14e28ce3f406a8b05761bed0d785d1ca8c2a5c6684d884c66a2 |