pub struct Editor { /* private fields */ }
Expand description
An editor is a builder for Commands. An Editor
instance represent’s a
user’s desired editor, and can be used repeatedly to open files.
Implementations§
Source§impl Editor
impl Editor
Sourcepub fn new() -> Result<Self, EditorBuilderError>
pub fn new() -> Result<Self, EditorBuilderError>
Create an editor from the user’s $VISUAL
or $EDITOR
environment
variables. This is the easiest way to create an editor, but provides no
flexibility. See the crate-level
documentation for an example of how
to use EditorBuilder to customize overrides and fallbacks.
Editor::new().unwrap();
// is equivalent to
EditorBuilder::new().environment().build().unwrap();
§Errors
Returns an error if:
- Neither
$VISUAL
nor$EDITOR
is defined - The command fails to parse (e.g. dangling quote)
Sourcepub fn open_at(&self, path: impl AsRef<Path>, line: u32, column: u32) -> Command
pub fn open_at(&self, path: impl AsRef<Path>, line: u32, column: u32) -> Command
Build a command that will open a file to a particular line and column.
Most editors accept the format path:line:column
, so that’s used by
default. This method supports some specific editors that don’t follow
that convention. It will automatically detect these editors based on the
invoked command and pass the line/column accordingly:
emacs
vi
/vim
/nvim
nano
(column not supported)
If you want support for another editor that’s not listed here, please open an issue on GitHub.