import { edit } from "https://deno.land/x/ayonli_jsext@v0.9.72/cli.ts";
Opens the given file in a text editor.
The filename
can include a line number by appending :<number>
or #L<number>
,
however, this feature is not supported by all editors.
This function will try to open VS Code if available, otherwise it will try to
open the default editor or a preferred one, such as vim
or nano
when available.
Some editor may hold the terminal until the editor is closed, while others may return immediately. Anyway, the operation is asynchronous and the function will not block the thread.
In the browser, this function will always try to open the file in VS Code, regardless of whether it's available or not.
Examples
Example 1
Example 1
import { edit } from "@ayonli/jsext/cli";
await edit("path/to/file.txt");
await edit("path/to/file.txt:10"); // open the file at line 10