Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/function/mod.ts>chdir

๐Ÿ“š Standard module for denops.vim
Go to Latest
function chdir
import { chdir } from "https://deno.land/x/denops_std@v5.0.2/function/mod.ts";

Change the current working directory to {dir}. The scope of the directory change depends on the directory of the current window: - If the current window has a window-local directory (:lcd), then changes the window local directory. - Otherwise, if the current tabpage has a local directory (:tcd) then changes the tabpage local directory. - Otherwise, changes the global directory. {dir} must be a String. If successful, returns the previous working directory. Pass this to another chdir() to restore the directory. On failure, returns an empty string.

Example:

let save_dir = chdir(newdir)
if save_dir != ""
   " ... do some work
   call chdir(save_dir)
endif

Can also be used as a method:

GetDir()->chdir()

Parameters

denops: Denops
dir: unknown

Returns

Promise<string>