comparison runtime/doc/eval.txt @ 16576:bcc343175103 v8.1.1291

patch 8.1.1291: not easy to change directory and restore commit https://github.com/vim/vim/commit/1063f3d2008f22d02ccfa9dab83a23db52febbdc Author: Bram Moolenaar <Bram@vim.org> Date: Tue May 7 22:06:52 2019 +0200 patch 8.1.1291: not easy to change directory and restore Problem: Not easy to change directory and restore. Solution: Add the chdir() function. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4358)
author Bram Moolenaar <Bram@vim.org>
date Tue, 07 May 2019 22:15:05 +0200
parents 0e473e9e70c2
children ff3c99bd1038
comparison
equal deleted inserted replaced
16575:e0baba49b677 16576:bcc343175103
2271 none set options for {handle} 2271 none set options for {handle}
2272 ch_status({handle} [, {options}]) 2272 ch_status({handle} [, {options}])
2273 String status of channel {handle} 2273 String status of channel {handle}
2274 changenr() Number current change number 2274 changenr() Number current change number
2275 char2nr({expr} [, {utf8}]) Number ASCII/UTF8 value of first char in {expr} 2275 char2nr({expr} [, {utf8}]) Number ASCII/UTF8 value of first char in {expr}
2276 chdir({dir}) String change current working directory
2276 cindent({lnum}) Number C indent for line {lnum} 2277 cindent({lnum}) Number C indent for line {lnum}
2277 clearmatches([{win}]) none clear all matches 2278 clearmatches([{win}]) none clear all matches
2278 col({expr}) Number column nr of cursor or mark 2279 col({expr}) Number column nr of cursor or mark
2279 complete({startcol}, {matches}) none set Insert mode completion 2280 complete({startcol}, {matches}) none set Insert mode completion
2280 complete_add({expr}) Number add completion match 2281 complete_add({expr}) Number add completion match
3467 To turn a string into a list of character numbers: > 3468 To turn a string into a list of character numbers: >
3468 let str = "ABC" 3469 let str = "ABC"
3469 let list = map(split(str, '\zs'), {_, val -> char2nr(val)}) 3470 let list = map(split(str, '\zs'), {_, val -> char2nr(val)})
3470 < Result: [65, 66, 67] 3471 < Result: [65, 66, 67]
3471 3472
3473 chdir({dir}) *chdir()*
3474 Change the current working directory to {dir}. The scope of
3475 the directory change depends on the directory of the current
3476 window:
3477 - If the current window has a window-local directory
3478 (|:lcd|), then changes the window local directory.
3479 - Otherwise, if the current tabpage has a local
3480 directory (|:tcd|) then changes the tabpage local
3481 directory.
3482 - Otherwise, changes the global directory.
3483 If successful, returns the previous working directory. Pass
3484 this to another chdir() to restore the directory.
3485 On failure, returns an empty string.
3486
3487 Example: >
3488 let save_dir = chdir(newdir)
3489 if save_dir
3490 " ... do some work
3491 call chdir(save_dir)
3492 endif
3493 <
3472 cindent({lnum}) *cindent()* 3494 cindent({lnum}) *cindent()*
3473 Get the amount of indent for line {lnum} according the C 3495 Get the amount of indent for line {lnum} according the C
3474 indenting rules, as with 'cindent'. 3496 indenting rules, as with 'cindent'.
3475 The indent is counted in spaces, the value of 'tabstop' is 3497 The indent is counted in spaces, the value of 'tabstop' is
3476 relevant. {lnum} is used just like in |getline()|. 3498 relevant. {lnum} is used just like in |getline()|.