diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-05-07 22:06:52 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-05-07 22:06:52 +0200 |
commit | 1063f3d2008f22d02ccfa9dab83a23db52febbdc (patch) | |
tree | ed4a5e7fddc01bdf2abb1d0d7931010c724d4ac5 /runtime | |
parent | fd31e45e4bccd7070d02e4d20bcab1f45b271600 (diff) |
patch 8.1.1291: not easy to change directory and restorev8.1.1291
Problem: Not easy to change directory and restore.
Solution: Add the chdir() function. (Yegappan Lakshmanan, closes #4358)
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/eval.txt | 22 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index a39f72b551..84001b7a02 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2273,6 +2273,7 @@ ch_status({handle} [, {options}]) String status of channel {handle} changenr() Number current change number char2nr({expr} [, {utf8}]) Number ASCII/UTF8 value of first char in {expr} +chdir({dir}) String change current working directory cindent({lnum}) Number C indent for line {lnum} clearmatches([{win}]) none clear all matches col({expr}) Number column nr of cursor or mark @@ -3469,6 +3470,27 @@ char2nr({expr} [, {utf8}]) *char2nr()* let list = map(split(str, '\zs'), {_, val -> char2nr(val)}) < Result: [65, 66, 67] +chdir({dir}) *chdir()* + 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. + 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 +< cindent({lnum}) *cindent()* Get the amount of indent for line {lnum} according the C indenting rules, as with 'cindent'. diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index cef6fd793a..f874b073b9 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -769,6 +769,7 @@ System functions and manipulation of files: haslocaldir() check if current window used |:lcd| or |:tcd| tempname() get the name of a temporary file mkdir() create a new directory + chdir() change current working directory delete() delete a file rename() rename a file system() get the result of a shell command as a string |