Skip to main content

openeditor

Edit files with your $EDITOR, like git commit does.

Usage

Install with: pip install openeditor

# Let user edit file
s = openeditor.edit_file("path/to/my/file.txt")
print("The file now contains:\n" + s)

# Use a temp file
s = openeditor.edit_file(
    "# Please edit this file, save and close editor when done", 
    "path/to/my/file.txt"
)
print("The file now contains:\n" + s) 

The editor is obtained from, in order of precedence:

  • $VISUAL
  • $EDITOR

If neither of these provide a useful editor, an exception will be thrown.

Limitations

openeditor expects an editor string similar to EDITOR=cmd such that:

  1. cmd file.txt (filename as the final argument) is a correct way of editing file.txt.
  2. cmd is not too complex. Simple things like space-separated flags (eg. EDITOR="vim -n") are fine but advanced shell magic may break.

If your cmd does need to be more complex, one possible workaround is to write a wrapper script that presents a compatible command-line interface to openeditor and invokes the full command as appopriate.

Release files for openeditor 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openeditor 0.3.1
File Size Uploaded
openeditor-0.3.1.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for openeditor 0.3.1
File Interpreter ABI Platform
openeditor-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 7.1 kB

Release files / openeditor-0.3.1.tar.gz

Download URL openeditor-0.3.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
415d2f847b12a112f8d16989c37a697c93fd3b60f4cbf27d180f7815f08c132a
BLAKE2b-256 checksum
How to use checksums
462c36fe02e5f3a64849dd1a638921bc86fedfc6a4b59b39b180a9ba331ef6a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.3 Linux/5.10.30-1-MANJARO

Release files / openeditor-0.3.1-py3-none-any.whl

Download URL openeditor-0.3.1-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
251c792a10fe67bdd6b8b31b9ba4264a349f38740ddad0a5a47223c8bc85d26b
BLAKE2b-256 checksum
How to use checksums
ebb6b3cf4bcbe8b416872736da91da224203c65e93ad452c41a387a1524c4e16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.3 Linux/5.10.30-1-MANJARO

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page