1- *channel.txt* For Vim version 7.4. Last change: 2016 Mar 12
1+ *channel.txt* For Vim version 7.4. Last change: 2016 Mar 14
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -127,18 +127,18 @@ Use |ch_status()| to see if the channel could be opened.
127127 "js" - Use JS (JavaScript) encoding, more efficient than JSON.
128128 "nl" - Use messages that end in a NL character
129129 "raw" - Use raw messages
130-
131- "in-mode " mode specifically for stdin, only when using pipes
132- "out-mode " mode specifically for stdout, only when using pipes
133- "err-mode " mode specifically for stderr, only when using pipes
130+ *in_mode* *out_mode* *err_mode*
131+ "in_mode " mode specifically for stdin, only when using pipes
132+ "out_mode " mode specifically for stdout, only when using pipes
133+ "err_mode " mode specifically for stderr, only when using pipes
134134 Note: when setting "mode" the part specific mode is
135135 overwritten. Therefore set "mode" first and the part specific
136136 mode later.
137137
138138 Note: when writing to a file or buffer and when reading from a
139139 buffer NL mode is used by default.
140140
141- *channel-callback*
141+ *channel-callback* *E921 *
142142"callback" A function that is called when a message is received that is
143143 not handled otherwise. It gets two arguments: the channel
144144 and the received message. Example: >
@@ -153,17 +153,17 @@ Use |ch_status()| to see if the channel could be opened.
153153 excluding the NL.
154154 When "mode" is "raw" the "msg" argument is the whole message
155155 as a string.
156- *out-cb *
157- "out-cb " A function like "callback" but used for stdout. Only for when
158- the channel uses pipes. When "out-cb " wasn't set the channel
156+ *out_cb *
157+ "out_cb " A function like "callback" but used for stdout. Only for when
158+ the channel uses pipes. When "out_cb " wasn't set the channel
159159 callback is used.
160- *err-cb *
161- "err-cb " A function like "callback" but used for stderr. Only for when
162- the channel uses pipes. When "err-cb " wasn't set the channel
160+ *err_cb *
161+ "err_cb " A function like "callback" but used for stderr. Only for when
162+ the channel uses pipes. When "err_cb " wasn't set the channel
163163 callback is used.
164164
165- *close-cb *
166- "close-cb " A function that is called when the channel gets closed, other
165+ *close_cb *
166+ "close_cb " A function that is called when the channel gets closed, other
167167 than by calling ch_close(). It should be defined like this: >
168168 func MyCloseHandler(channel)
169169< *waittime*
@@ -179,9 +179,9 @@ Use |ch_status()| to see if the channel could be opened.
179179"timeout" The time to wait for a request when blocking, E.g. when using
180180 ch_evalexpr(). In milliseconds. The default is 2000 (2
181181 seconds).
182- *out-timeout * *err-timeout *
183- "out-timeout " Timeout for stdout. Only when using pipes.
184- "err-timeout " Timeout for stderr. Only when using pipes.
182+ *out_timeout * *err_timeout *
183+ "out_timeout " Timeout for stdout. Only when using pipes.
184+ "err_timeout " Timeout for stderr. Only when using pipes.
185185 Note: when setting "timeout" the part specific mode is
186186 overwritten. Therefore set "timeout" first and the part
187187 specific mode later.
@@ -440,18 +440,18 @@ been received and not parsed correctly.
440440
441441If the command produces a line of output that you want to deal with, specify
442442a handler for stdout: >
443- let job = job_start(command, {"out-cb ": "MyHandler"})
443+ let job = job_start(command, {"out_cb ": "MyHandler"})
444444 The function will be called with the channel and a message. You would define
445445it like this: >
446446 func MyHandler(channel, msg)
447447
448448 Without the handler you need to read the output with | ch_read() | or
449449| ch_readraw() | .
450450
451- The handler defined for "out-cb " will not receive stderr. If you want to
452- handle that separately, add an "err-cb " handler: >
453- let job = job_start(command, {"out-cb ": "MyHandler",
454- \ "err-cb ": "ErrHandler"})
451+ The handler defined for "out_cb " will not receive stderr. If you want to
452+ handle that separately, add an "err_cb " handler: >
453+ let job = job_start(command, {"out_cb ": "MyHandler",
454+ \ "err_cb ": "ErrHandler"})
455455
456456 If you want to handle both stderr and stdout with one handler use the
457457"callback" option: >
@@ -463,24 +463,24 @@ JSON or JS mode you can use ch_evalexpr().
463463There are several options you can use, see | job-options | .
464464For example, to start a job and write its output in buffer "dummy": >
465465 let logjob = job_start("tail -f /tmp/log",
466- \ {'out-io ': 'buffer', 'out-name ': 'dummy'})
466+ \ {'out_io ': 'buffer', 'out_name ': 'dummy'})
467467 sbuf dummy
468468
469469
470470Job input from a buffer ~
471471
472472To run a job that reads from a buffer: >
473473 let job = job_start({command},
474- \ {'in-io ': 'buffer', 'in-name ': 'mybuffer'})
474+ \ {'in_io ': 'buffer', 'in_name ': 'mybuffer'})
475475<
476476 *E915* *E918*
477477The buffer is found by name, similar to | bufnr() | . The buffer must exist and
478478be loaded when job_start() is called.
479479
480- By default this reads the whole buffer. This can be changed with the "in-top "
481- and "in-bot " options.
480+ By default this reads the whole buffer. This can be changed with the "in_top "
481+ and "in_bot " options.
482482
483- A special mode is when "in-top " is set to zero and "in-bot " is not set: Every
483+ A special mode is when "in_top " is set to zero and "in_bot " is not set: Every
484484time a line is added to the buffer, the last-but-one line will be send to the
485485job stdin. This allows for editing the last line and sending it when pressing
486486Enter.
@@ -490,7 +490,7 @@ Enter.
490490
491491To start another process without creating a channel: >
492492 let job = job_start(command,
493- \ {"in-io ": "null", "out-io ": "null", "err-io ": "null"})
493+ \ {"in_io ": "null", "out_io ": "null", "err_io ": "null"})
494494
495495 This starts {command} in the background, Vim does not wait for it to finish.
496496
@@ -524,17 +524,17 @@ See |job_setoptions()| and |ch_setoptions()|.
524524 *job-callback*
525525"callback": handler Callback for something to read on any part of the
526526 channel.
527- *job-out-cb *
528- "out-cb ": handler Callback for when there is something to read on
527+ *job-out_cb *
528+ "out_cb ": handler Callback for when there is something to read on
529529 stdout.
530- *job-err-cb *
531- "err-cb ": handler Callback for when there is something to read on
530+ *job-err_cb *
531+ "err_cb ": handler Callback for when there is something to read on
532532 stderr.
533- *job-close-cb *
534- "close-cb ": handler Callback for when the channel is closed. Same as
535- "close-cb " on ch_open().
536- *job-exit-cb *
537- "exit-cb ": handler Callback for when the job ends. The arguments are the
533+ *job-close_cb *
534+ "close_cb ": handler Callback for when the channel is closed. Same as
535+ "close_cb " on ch_open().
536+ *job-exit_cb *
537+ "exit_cb ": handler Callback for when the job ends. The arguments are the
538538 job and the exit status.
539539 Vim checks about every 10 seconds for jobs that ended.
540540 The callback can also be triggered by calling
@@ -557,37 +557,37 @@ See |job_setoptions()| and |ch_setoptions()|.
557557 cause I/O errors.
558558 Existing callbacks and other settings remain.
559559
560- *job-in-io * *in-top * *in-bot * *in-name * *in-buf *
561- "in-io ": "null" disconnect stdin (read from /dev/null)
562- "in-io ": "pipe" stdin is connected to the channel (default)
563- "in-io ": "file" stdin reads from a file
564- "in-io ": "buffer" stdin reads from a buffer
565- "in-top ": number when using "buffer": first line to send (default: 1)
566- "in-bot ": number when using "buffer": last line to send (default: last)
567- "in-name ": "/path/file" the name of the file or buffer to read from
568- "in-buf ": number the number of the buffer to read from
569-
570- *job-out-io * *out-name * *out-buf *
571- "out-io ": "null" disconnect stdout (goes to /dev/null)
572- "out-io ": "pipe" stdout is connected to the channel (default)
573- "out-io ": "file" stdout writes to a file
574- "out-io ": "buffer" stdout appends to a buffer
575- "out-name ": "/path/file" the name of the file or buffer to write to
576- "out-buf ": number the number of the buffer to write to
577-
578- *job-err-io * *err-name * *err-buf *
579- "err-io ": "out" stderr messages to go to stdout
580- "err-io ": "null" disconnect stderr (goes to /dev/null)
581- "err-io ": "pipe" stderr is connected to the channel (default)
582- "err-io ": "file" stderr writes to a file
583- "err-io ": "buffer" stderr appends to a buffer
584- "err-name ": "/path/file" the name of the file or buffer to write to
585- "err-buf ": number the number of the buffer to write to
560+ *job-in_io * *in_top * *in_bot * *in_name * *in_buf *
561+ "in_io ": "null" disconnect stdin (read from /dev/null)
562+ "in_io ": "pipe" stdin is connected to the channel (default)
563+ "in_io ": "file" stdin reads from a file
564+ "in_io ": "buffer" stdin reads from a buffer
565+ "in_top ": number when using "buffer": first line to send (default: 1)
566+ "in_bot ": number when using "buffer": last line to send (default: last)
567+ "in_name ": "/path/file" the name of the file or buffer to read from
568+ "in_buf ": number the number of the buffer to read from
569+
570+ *job-out_io * *out_name * *out_buf *
571+ "out_io ": "null" disconnect stdout (goes to /dev/null)
572+ "out_io ": "pipe" stdout is connected to the channel (default)
573+ "out_io ": "file" stdout writes to a file
574+ "out_io ": "buffer" stdout appends to a buffer
575+ "out_name ": "/path/file" the name of the file or buffer to write to
576+ "out_buf ": number the number of the buffer to write to
577+
578+ *job-err_io * *err_name * *err_buf *
579+ "err_io ": "out" stderr messages to go to stdout
580+ "err_io ": "null" disconnect stderr (goes to /dev/null)
581+ "err_io ": "pipe" stderr is connected to the channel (default)
582+ "err_io ": "file" stderr writes to a file
583+ "err_io ": "buffer" stderr appends to a buffer
584+ "err_name ": "/path/file" the name of the file or buffer to write to
585+ "err_buf ": number the number of the buffer to write to
586586
587587
588588Writing to a buffer ~
589589
590- When the out-io or err-io mode is "buffer" and there is a callback, the text
590+ When the out_io or err_io mode is "buffer" and there is a callback, the text
591591is appended to the buffer before invoking the callback.
592592
593593When a buffer is used both for input and output, the output lines are put
@@ -614,7 +614,7 @@ Undo is synced for every added line.
614614
615615
616616Writing to a file ~
617-
617+ *E920*
618618The file is created with permissions 600 (read-write for the user, not
619619accessible for others). Use | setfperm() | to change this.
620620
0 commit comments