import { open } from "https://deno.land/x/denops_std@v6.5.1/buffer/buffer.ts";
Open a bufname
buffer with given options on the current window
import type { Entrypoint } from "https://deno.land/x/denops_std@v6.5.1/mod.ts";
import { open } from "https://deno.land/x/denops_std@v6.5.1/buffer/mod.ts";
export const main: Entrypoint = async (denops) => {
// Open `README.md`
// Same as `:edit README.md`
await open(denops, "README.md");
// Open `LICENSE` with given options
// Same as `:keepjumps keepalt edit ++enc=sjis ++ff=dos LICENSE`
await open(denops, "LICENSE", {
mods: "keepjumps keepalt",
cmdarg: "++enc=sjis ++ff=dos",
});
}
Use split
, vsplit
, tabedit
, pedit
, or whatever in opener
attribute of
the option like:
import type { Entrypoint } from "https://deno.land/x/denops_std@v6.5.1/mod.ts";
import { open } from "https://deno.land/x/denops_std@v6.5.1/buffer/mod.ts";
export const main: Entrypoint = async (denops) => {
await open(denops, "README.md", { opener: "split" });
}
Use a result value if you need window id, buffer number, window number, or tabpage number like:
import type { Entrypoint } from "https://deno.land/x/denops_std@v6.5.1/mod.ts";
import { open } from "https://deno.land/x/denops_std@v6.5.1/buffer/mod.ts";
export const main: Entrypoint = async (denops) => {
const info = await open(denops, "README.md");
console.log("winid:", info.winid);
console.log("bufnr:", info.bufnr);
console.log("winnr:", info.winnr);
console.log("tabpagenr:", info.tabpagenr);
}
Returns
Promise<OpenResult>