Skip to content

Commit 2ec2921

Browse files
committed
Added README.md
1 parent 9a3a325 commit 2ec2921

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
`python-editor` is a library that provides the `editor` module for programmatically
2+
interfacing with your system's $EDITOR.
3+
4+
Examples
5+
--------
6+
7+
```
8+
import editor
9+
commit_msg = editor.edit(contents="# Enter commit message here")
10+
```
11+
Opens an editor, prefilled with the contents, "# Enter commit messdage here".
12+
When the editor is closed, returns the contents in variable `commit_msg`.
13+
14+
15+
```
16+
import editor
17+
editor.edit(file="README.txt")
18+
```
19+
Opens README.txt in an editor. Changes are saved in place.
20+
21+
22+
How it Works
23+
------------
24+
`editor` first looks for the ${EDITOR} environment variable. If set, it uses
25+
the value as-is, without fallbacks.
26+
27+
If no $EDITOR is set, editor will search through a list of known editors, and
28+
use the first one that exists on the system.
29+
30+
For example, on Linux, `editor` will look for the following editors in order:
31+
32+
* vim
33+
* emacs
34+
* nano
35+
36+
When calling the `edit()` function, `editor` will open the editor in a subprocess,
37+
inheriting the parent process's stdin, stdout

0 commit comments

Comments
 (0)