Expand description
edit
lets you open and edit something in a text editor, regardless of platform.
(Think git commit
.)
It works on Windows, Mac, and Linux, and knows about lots of different text editors to fall
back upon in case standard environment variables such as VISUAL
and EDITOR
aren’t set.
ⓘ
let template = "Fill in the blank: Hello, _____!";
let edited = edit::edit(template)?;
println!("after editing: '{}'", edited);
// after editing: 'Fill in the blank: Hello, world!'
Features
The edit
crate has the following optional features:
-
better-path
(enabled by default) — Usewhich
to locate executable programs inPATH
. If this is disabled, programs are still looked up inPATH
, but a basic search is used that does not check for executability. -
quoted-env
— Useshell-words
to split apart the values of theVISUAL
andEDITOR
environment variables. If this is disabled, the envvars are split up on whitespace.
Structs
- Create a new temporary file or directory with custom parameters.
Functions
- Open the contents of a string or buffer in the default editor.
- Open the contents of a string or buffer in the default editor and return them as raw bytes.
- Open the contents of a string or buffer in the default editor using a temporary file with a custom path or filename and return them as raw bytes.
- Open an existing file (or create a new one, depending on the editor’s behavior) in the default editor and wait for the editor to exit.
- Open the contents of a string or buffer in the default editor using a temporary file with a custom path or filename.
- Find the system default editor, if there is one.