comparison runtime/doc/eval.txt @ 8031:ece323e2b57f v7.4.1310

commit https://github.com/vim/vim/commit/6463ca229cb9412581419497924c85fcbfc854ab Author: Bram Moolenaar <Bram@vim.org> Date: Sat Feb 13 17:04:46 2016 +0100 patch 7.4.1310 Problem: Jobs don't open a channel. Solution: Create pipes and add them to the channel. Add ch_logfile(). Only Unix for now.
author Christian Brabandt <cb@256bit.org>
date Sat, 13 Feb 2016 17:15:05 +0100
parents d685893d852e
children abd64cf67bcf
comparison
equal deleted inserted replaced
8030:05f57db9d8da 8031:ece323e2b57f
1 *eval.txt* For Vim version 7.4. Last change: 2016 Feb 07 1 *eval.txt* For Vim version 7.4. Last change: 2016 Feb 13
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
1414 :endtry 1414 :endtry
1415 < Output: "caught oops". 1415 < Output: "caught oops".
1416 1416
1417 *v:false* *false-variable* 1417 *v:false* *false-variable*
1418 v:false A Number with value zero. Used to put "false" in JSON. See 1418 v:false A Number with value zero. Used to put "false" in JSON. See
1419 |jsonencode()|. 1419 |json_encode()|.
1420 When used as a string this evaluates to "false". > 1420 When used as a string this evaluates to "false". >
1421 echo v:false 1421 echo v:false
1422 < false ~ 1422 < false ~
1423 1423
1424 *v:fcs_reason* *fcs_reason-variable* 1424 *v:fcs_reason* *fcs_reason-variable*
1554 This is the screen column number, like with |virtcol()|. The 1554 This is the screen column number, like with |virtcol()|. The
1555 value is zero when there was no mouse button click. 1555 value is zero when there was no mouse button click.
1556 1556
1557 *v:none* *none-variable* 1557 *v:none* *none-variable*
1558 v:none An empty String. Used to put an empty item in JSON. See 1558 v:none An empty String. Used to put an empty item in JSON. See
1559 |jsonencode()|. 1559 |json_encode()|.
1560 When used as a number this evaluates to zero. 1560 When used as a number this evaluates to zero.
1561 When used as a string this evaluates to "none". > 1561 When used as a string this evaluates to "none". >
1562 echo v:none 1562 echo v:none
1563 < none ~ 1563 < none ~
1564 1564
1565 *v:null* *null-variable* 1565 *v:null* *null-variable*
1566 v:null An empty String. Used to put "null" in JSON. See 1566 v:null An empty String. Used to put "null" in JSON. See
1567 |jsonencode()|. 1567 |json_encode()|.
1568 When used as a number this evaluates to zero. 1568 When used as a number this evaluates to zero.
1569 When used as a string this evaluates to "null". > 1569 When used as a string this evaluates to "null". >
1570 echo v:null 1570 echo v:null
1571 < null ~ 1571 < null ~
1572 1572
1735 :endtry 1735 :endtry
1736 < Output: "Exception from test.vim, line 2" 1736 < Output: "Exception from test.vim, line 2"
1737 1737
1738 *v:true* *true-variable* 1738 *v:true* *true-variable*
1739 v:true A Number with value one. Used to put "true" in JSON. See 1739 v:true A Number with value one. Used to put "true" in JSON. See
1740 |jsonencode()|. 1740 |json_encode()|.
1741 When used as a string this evaluates to "true". > 1741 When used as a string this evaluates to "true". >
1742 echo v:true 1742 echo v:true
1743 < true ~ 1743 < true ~
1744 *v:val* *val-variable* 1744 *v:val* *val-variable*
1745 v:val Value of the current item of a |List| or |Dictionary|. Only 1745 v:val Value of the current item of a |List| or |Dictionary|. Only
1814 byteidxcomp( {expr}, {nr}) Number byte index of {nr}'th char in {expr} 1814 byteidxcomp( {expr}, {nr}) Number byte index of {nr}'th char in {expr}
1815 call( {func}, {arglist} [, {dict}]) 1815 call( {func}, {arglist} [, {dict}])
1816 any call {func} with arguments {arglist} 1816 any call {func} with arguments {arglist}
1817 ceil( {expr}) Float round {expr} up 1817 ceil( {expr}) Float round {expr} up
1818 ch_close( {handle}) none close a channel 1818 ch_close( {handle}) none close a channel
1819 ch_logfile( {fname} [, {mode}]) none start logging channel activity
1819 ch_open( {address} [, {argdict})] Number open a channel to {address} 1820 ch_open( {address} [, {argdict})] Number open a channel to {address}
1821 ch_readraw( {handle}) String read from channel {handle}
1820 ch_sendexpr( {handle}, {expr} [, {callback}]) 1822 ch_sendexpr( {handle}, {expr} [, {callback}])
1821 any send {expr} over JSON channel {handle} 1823 any send {expr} over JSON channel {handle}
1822 ch_sendraw( {handle}, {string} [, {callback}]) 1824 ch_sendraw( {handle}, {string} [, {callback}])
1823 any send {string} over raw channel {handle} 1825 any send {string} over raw channel {handle}
1824 changenr() Number current change number 1826 changenr() Number current change number
1978 rhs of mapping {name} in mode {mode} 1980 rhs of mapping {name} in mode {mode}
1979 mapcheck( {name}[, {mode} [, {abbr}]]) 1981 mapcheck( {name}[, {mode} [, {abbr}]])
1980 String check for mappings matching {name} 1982 String check for mappings matching {name}
1981 match( {expr}, {pat}[, {start}[, {count}]]) 1983 match( {expr}, {pat}[, {start}[, {count}]])
1982 Number position where {pat} matches in {expr} 1984 Number position where {pat} matches in {expr}
1983 matchadd( {group}, {pattern}[, {priority}[, {id}]]) 1985 matchadd( {group}, {pattern}[, {priority}[, {id} [, {dict}]]])
1984 Number highlight {pattern} with {group} 1986 Number highlight {pattern} with {group}
1985 matchaddpos( {group}, {list}[, {priority}[, {id}]]) 1987 matchaddpos( {group}, {pos}[, {priority}[, {id}[, {dict}]]])
1986 Number highlight positions with {group} 1988 Number highlight positions with {group}
1987 matcharg( {nr}) List arguments of |:match| 1989 matcharg( {nr}) List arguments of |:match|
1988 matchdelete( {id}) Number delete match identified by {id} 1990 matchdelete( {id}) Number delete match identified by {id}
1989 matchend( {expr}, {pat}[, {start}[, {count}]]) 1991 matchend( {expr}, {pat}[, {start}[, {count}]])
1990 Number position where {pat} ends in {expr} 1992 Number position where {pat} ends in {expr}
2272 When {error} is given it must match |v:errmsg|. 2274 When {error} is given it must match |v:errmsg|.
2273 2275
2274 assert_false({actual} [, {msg}]) *assert_false()* 2276 assert_false({actual} [, {msg}]) *assert_false()*
2275 When {actual} is not false an error message is added to 2277 When {actual} is not false an error message is added to
2276 |v:errors|, like with |assert_equal()|. 2278 |v:errors|, like with |assert_equal()|.
2277 A value is false when it is zero. When "{actual}" is not a 2279 A value is false when it is zero. When {actual} is not a
2278 number the assert fails. 2280 number the assert fails.
2279 When {msg} is omitted an error in the form "Expected False but 2281 When {msg} is omitted an error in the form "Expected False but
2280 got {actual}" is produced. 2282 got {actual}" is produced.
2281 2283
2282 assert_true({actual} [, {msg}]) *assert_true()* 2284 assert_true({actual} [, {msg}]) *assert_true()*
2674 the buttons are always put vertically. Otherwise, confirm() 2676 the buttons are always put vertically. Otherwise, confirm()
2675 tries to put the buttons in one horizontal line. If they 2677 tries to put the buttons in one horizontal line. If they
2676 don't fit, a vertical layout is used anyway. For some systems 2678 don't fit, a vertical layout is used anyway. For some systems
2677 the horizontal layout is always used. 2679 the horizontal layout is always used.
2678 2680
2679 ch_close({handle}) *ch_close()* 2681 ch_close({handle}) *ch_close()*
2680 Close channel {handle}. See |channel|. 2682 Close channel {handle}. See |channel|.
2681 {only available when compiled with the |+channel| feature} 2683 {only available when compiled with the |+channel| feature}
2684
2685 ch_logfile( {fname} [, {mode}]) *ch_logfile()*
2686 Start logging channel activity to {fname}.
2687 When {mode} is omitted or "a" append to the file.
2688 When {mode} is "w" start with an empty file.
2689 When {fname} is an empty string: stop logging.
2682 2690
2683 ch_open({address} [, {argdict}]) *ch_open()* 2691 ch_open({address} [, {argdict}]) *ch_open()*
2684 Open a channel to {address}. See |channel|. 2692 Open a channel to {address}. See |channel|.
2685 Returns the channel handle on success. Returns a negative 2693 Returns the channel handle on success. Returns a negative
2686 number for failure. 2694 number for failure.
2701 timeout Specify response read timeout value as 2709 timeout Specify response read timeout value as
2702 milliseconds. 2710 milliseconds.
2703 Default: 2000. 2711 Default: 2000.
2704 {only available when compiled with the |+channel| feature} 2712 {only available when compiled with the |+channel| feature}
2705 2713
2706 ch_sendexpr({handle}, {expr} [, {callback}]) *ch_sendexpr()* 2714 ch_readraw({handle}) *ch_readraw()*
2715 Read from channel {handle} and return the received message.
2716 This uses the channel timeout. When there is nothing to read
2717 within that time an empty string is returned.
2718 TODO: depends on channel mode.
2719
2720 ch_sendexpr({handle}, {expr} [, {callback}]) *ch_sendexpr()*
2707 Send {expr} over channel {handle}. The {expr} is encoded 2721 Send {expr} over channel {handle}. The {expr} is encoded
2708 according to the type of channel. The function cannot be used 2722 according to the type of channel. The function cannot be used
2709 with a raw channel. See |channel-use|. *E912* 2723 with a raw channel. See |channel-use|. *E912*
2710 2724
2711 When {callback} is given returns immediately. Without 2725 When {callback} is given returns immediately. Without
2842 deepcopy({expr}[, {noref}]) *deepcopy()* *E698* 2856 deepcopy({expr}[, {noref}]) *deepcopy()* *E698*
2843 Make a copy of {expr}. For Numbers and Strings this isn't 2857 Make a copy of {expr}. For Numbers and Strings this isn't
2844 different from using {expr} directly. 2858 different from using {expr} directly.
2845 When {expr} is a |List| a full copy is created. This means 2859 When {expr} is a |List| a full copy is created. This means
2846 that the original |List| can be changed without changing the 2860 that the original |List| can be changed without changing the
2847 copy, and vice versa. When an item is a |List|, a copy for it 2861 copy, and vice versa. When an item is a |List| or
2848 is made, recursively. Thus changing an item in the copy does 2862 |Dictionary|, a copy for it is made, recursively. Thus
2849 not change the contents of the original |List|. 2863 changing an item in the copy does not change the contents of
2864 the original |List|.
2865 A |Dictionary| is copied in a similar way as a |List|.
2850 When {noref} is omitted or zero a contained |List| or 2866 When {noref} is omitted or zero a contained |List| or
2851 |Dictionary| is only copied once. All references point to 2867 |Dictionary| is only copied once. All references point to
2852 this single copy. With {noref} set to 1 every occurrence of a 2868 this single copy. With {noref} set to 1 every occurrence of a
2853 |List| or |Dictionary| results in a new copy. This also means 2869 |List| or |Dictionary| results in a new copy. This also means
2854 that a cyclic reference causes deepcopy() to fail. 2870 that a cyclic reference causes deepcopy() to fail.
2904 line, "'m" mark m, etc. 2920 line, "'m" mark m, etc.
2905 {col} is 1 for the leftmost column, {lnum} is 1 for the first 2921 {col} is 1 for the leftmost column, {lnum} is 1 for the first
2906 line. 2922 line.
2907 The highlight ID can be used with |synIDattr()| to obtain 2923 The highlight ID can be used with |synIDattr()| to obtain
2908 syntax information about the highlighting. 2924 syntax information about the highlighting.
2925
2926 *disable_char_avail_for_testing()*
2927 disable_char_avail_for_testing({expr})
2928 When {expr} is 1 the internal char_avail() function will
2929 return FALSE. When {expr} is 0 the char_avail() function will
2930 function normally.
2931 Only use this for a test where typeahead causes the test not
2932 to work. E.g., to trigger the CursorMovedI autocommand event.
2909 2933
2910 empty({expr}) *empty()* 2934 empty({expr}) *empty()*
2911 Return the Number 1 if {expr} is empty, zero otherwise. 2935 Return the Number 1 if {expr} is empty, zero otherwise.
2912 - A |List| or |Dictionary| is empty when it does not have any 2936 - A |List| or |Dictionary| is empty when it does not have any
2913 items. 2937 items.
3935 if filename =~ '^Make.*\.mak$' 3959 if filename =~ '^Make.*\.mak$'
3936 < When {expr} is an empty string the result is "^$", match an 3960 < When {expr} is an empty string the result is "^$", match an
3937 empty string. 3961 empty string.
3938 3962
3939 *globpath()* 3963 *globpath()*
3940 globpath({path}, {expr} [, {nosuf} [, {list} [, {allinks}]]]) 3964 globpath({path}, {expr} [, {nosuf} [, {list} [, {alllinks}]]])
3941 Perform glob() on all directories in {path} and concatenate 3965 Perform glob() on all directories in {path} and concatenate
3942 the results. Example: > 3966 the results. Example: >
3943 :echo globpath(&rtp, "syntax/c.vim") 3967 :echo globpath(&rtp, "syntax/c.vim")
3944 < 3968 <
3945 {path} is a comma-separated list of directory names. Each 3969 {path} is a comma-separated list of directory names. Each
3961 also get filenames containing newlines correctly. Otherwise 3985 also get filenames containing newlines correctly. Otherwise
3962 the result is a String and when there are several matches, 3986 the result is a String and when there are several matches,
3963 they are separated by <NL> characters. Example: > 3987 they are separated by <NL> characters. Example: >
3964 :echo globpath(&rtp, "syntax/c.vim", 0, 1) 3988 :echo globpath(&rtp, "syntax/c.vim", 0, 1)
3965 < 3989 <
3966 {allinks} is used as with |glob()|. 3990 {alllinks} is used as with |glob()|.
3967 3991
3968 The "**" item can be used to search in a directory tree. 3992 The "**" item can be used to search in a directory tree.
3969 For example, to find all "README.txt" files in the directories 3993 For example, to find all "README.txt" files in the directories
3970 in 'runtimepath' and below: > 3994 in 'runtimepath' and below: >
3971 :echo globpath(&rtp, "**/README.txt") 3995 :echo globpath(&rtp, "**/README.txt")
4312 4336
4313 job_start({command} [, {options}]) *job_start()* 4337 job_start({command} [, {options}]) *job_start()*
4314 Start a job and return a Job object. Unlike |system()| and 4338 Start a job and return a Job object. Unlike |system()| and
4315 |:!cmd| this does not wait for the job to finish. 4339 |:!cmd| this does not wait for the job to finish.
4316 4340
4317 {command} can be a string. This works best on MS-Windows. On 4341 {command} can be a String. This works best on MS-Windows. On
4318 Unix it is split up in white-separated parts to be passed to 4342 Unix it is split up in white-separated parts to be passed to
4319 execvp(). Arguments in double quotes can contain white space. 4343 execvp(). Arguments in double quotes can contain white space.
4320 4344
4321 {command} can be a list, where the first item is the executable 4345 {command} can be a List, where the first item is the executable
4322 and further items are the arguments. All items are converted 4346 and further items are the arguments. All items are converted
4323 to String. This works best on Unix. 4347 to String. This works best on Unix.
4348
4349 On MS-Windows, job_start() makes a GUI application hidden. If
4350 want to show it, Use |:!start| instead.
4324 4351
4325 The command is executed directly, not through a shell, the 4352 The command is executed directly, not through a shell, the
4326 'shell' option is not used. To use the shell: > 4353 'shell' option is not used. To use the shell: >
4327 let job = job_start(["/bin/sh", "-c", "echo hello"]) 4354 let job = job_start(["/bin/sh", "-c", "echo hello"])
4328 < Or: > 4355 < Or: >
4329 let job = job_start('/bin/sh -c "echo hello"') 4356 let job = job_start('/bin/sh -c "echo hello"')
4330 < However, the status of the job will now be the status of the 4357 < Note that this will start two processes, the shell and the
4331 shell, and stopping the job means stopping the shell and the 4358 command it executes. If you don't want this use the "exec"
4332 command may continue to run. 4359 shell command.
4333 4360
4334 On Unix $PATH is used to search for the executable only when 4361 On Unix $PATH is used to search for the executable only when
4335 the command does not contain a slash. 4362 the command does not contain a slash.
4336 4363
4337 The job will use the same terminal as Vim. If it reads from 4364 The job will use the same terminal as Vim. If it reads from
4340 let job = job_start(['sh', '-c', "myserver </dev/null >/dev/null"]) 4367 let job = job_start(['sh', '-c', "myserver </dev/null >/dev/null"])
4341 < 4368 <
4342 The returned Job object can be used to get the status with 4369 The returned Job object can be used to get the status with
4343 |job_status()| and stop the job with |job_stop()|. 4370 |job_status()| and stop the job with |job_stop()|.
4344 4371
4345 {options} must be a Dictionary. It can contain these optional 4372 {options} must be a Dictionary. It can contain many optional
4346 items: 4373 items, see |job-options|.
4347 killonexit When non-zero kill the job when Vim 4374
4348 exits. (default: 0, don't kill) 4375 {only available when compiled with the |+job| feature}
4349
4350 {only available when compiled with the |+channel| feature}
4351 4376
4352 job_status({job}) *job_status()* 4377 job_status({job}) *job_status()*
4353 Returns a String with the status of {job}: 4378 Returns a String with the status of {job}:
4354 "run" job is running 4379 "run" job is running
4355 "fail" job failed to start 4380 "fail" job failed to start
4356 "dead" job died or was stopped after running 4381 "dead" job died or was stopped after running
4357 4382
4358 {only available when compiled with the |+channel| feature} 4383 {only available when compiled with the |+job| feature}
4359 4384
4360 job_stop({job} [, {how}]) *job_stop()* 4385 job_stop({job} [, {how}]) *job_stop()*
4361 Stop the {job}. This can also be used to signal the job. 4386 Stop the {job}. This can also be used to signal the job.
4362 4387
4363 When {how} is omitted or is "term" the job will be terminated 4388 When {how} is omitted or is "term" the job will be terminated
4364 normally. For Unix SIGTERM is sent. 4389 normally. For Unix SIGTERM is sent. For MS-Windows
4365 Other values: 4390 CTRL_BREAK will be sent. This goes to the process group, thus
4391 children may also be affected.
4392
4393 Other values for Unix:
4366 "hup" Unix: SIGHUP 4394 "hup" Unix: SIGHUP
4367 "quit" Unix: SIGQUIT 4395 "quit" Unix: SIGQUIT
4368 "kill" Unix: SIGKILL (strongest way to stop) 4396 "kill" Unix: SIGKILL (strongest way to stop)
4369 number Unix: signal with that number 4397 number Unix: signal with that number
4398
4399 Other values for MS-Windows:
4400 "int" Windows: CTRL_C
4401 "kill" Windows: terminate process forcedly
4402 Others Windows: CTRL_BREAK
4403
4404 On Unix the signal is sent to the process group. This means
4405 that when the job is "sh -c command" it affects both the shell
4406 and the command.
4370 4407
4371 The result is a Number: 1 if the operation could be executed, 4408 The result is a Number: 1 if the operation could be executed,
4372 0 if "how" is not supported on the system. 4409 0 if "how" is not supported on the system.
4373 Note that even when the operation was executed, whether the 4410 Note that even when the operation was executed, whether the
4374 job was actually stopped needs to be checked with 4411 job was actually stopped needs to be checked with
4375 job_status(). 4412 job_status().
4376 The operation will even be done when the job wasn't running. 4413 The status of the job isn't checked, the operation will even
4377 4414 be done when Vim thinks the job isn't running.
4378 {only available when compiled with the |+channel| feature} 4415
4416 {only available when compiled with the |+job| feature}
4379 4417
4380 join({list} [, {sep}]) *join()* 4418 join({list} [, {sep}]) *join()*
4381 Join the items in {list} together into one String. 4419 Join the items in {list} together into one String.
4382 When {sep} is specified it is put in between the items. If 4420 When {sep} is specified it is put in between the items. If
4383 {sep} is omitted a single space is used. 4421 {sep} is omitted a single space is used.
4771 The 'ignorecase' option is used to set the ignore-caseness of 4809 The 'ignorecase' option is used to set the ignore-caseness of
4772 the pattern. 'smartcase' is NOT used. The matching is always 4810 the pattern. 'smartcase' is NOT used. The matching is always
4773 done like 'magic' is set and 'cpoptions' is empty. 4811 done like 'magic' is set and 'cpoptions' is empty.
4774 4812
4775 *matchadd()* *E798* *E799* *E801* 4813 *matchadd()* *E798* *E799* *E801*
4776 matchadd({group}, {pattern}[, {priority}[, {id} [, {dict}]]]) 4814 matchadd({group}, {pattern}[, {priority}[, {id}[, {dict}]]])
4777 Defines a pattern to be highlighted in the current window (a 4815 Defines a pattern to be highlighted in the current window (a
4778 "match"). It will be highlighted with {group}. Returns an 4816 "match"). It will be highlighted with {group}. Returns an
4779 identification number (ID), which can be used to delete the 4817 identification number (ID), which can be used to delete the
4780 match using |matchdelete()|. 4818 match using |matchdelete()|.
4781 Matching is case sensitive and magic, unless case sensitivity 4819 Matching is case sensitive and magic, unless case sensitivity
4807 values. Currently this is used to specify a match specific 4845 values. Currently this is used to specify a match specific
4808 conceal character that will be shown for |hl-Conceal| 4846 conceal character that will be shown for |hl-Conceal|
4809 highlighted matches. The dict can have the following members: 4847 highlighted matches. The dict can have the following members:
4810 4848
4811 conceal Special character to show instead of the 4849 conceal Special character to show instead of the
4812 match (only for |hl-Conceal| highlighed 4850 match (only for |hl-Conceal| highlighted
4813 matches, see |:syn-cchar|) 4851 matches, see |:syn-cchar|)
4814 4852
4815 The number of matches is not limited, as it is the case with 4853 The number of matches is not limited, as it is the case with
4816 the |:match| commands. 4854 the |:match| commands.
4817 4855
6806 :if type(myvar) == type(function("tr")) 6844 :if type(myvar) == type(function("tr"))
6807 :if type(myvar) == type([]) 6845 :if type(myvar) == type([])
6808 :if type(myvar) == type({}) 6846 :if type(myvar) == type({})
6809 :if type(myvar) == type(0.0) 6847 :if type(myvar) == type(0.0)
6810 :if type(myvar) == type(v:false) 6848 :if type(myvar) == type(v:false)
6811 :if type(myvar) == type(v:none 6849 :if type(myvar) == type(v:none)
6812 6850
6813 undofile({name}) *undofile()* 6851 undofile({name}) *undofile()*
6814 Return the name of the undo file that would be used for a file 6852 Return the name of the undo file that would be used for a file
6815 with name {name} when writing. This uses the 'undodir' 6853 with name {name} when writing. This uses the 'undodir'
6816 option, finding directories that exist. It does not check if 6854 option, finding directories that exist. It does not check if