(`integer`)
byteidx({expr}, {nr} [, {utf16}]) *byteidx()*
Return byte index of the {nr}th character in the String
{expr}. Use zero for the first character, it then returns
zero.
If there are no multibyte characters the returned value is
equal to {nr}.
Composing characters are not counted separately, their byte
length is added to the preceding base character. See
|byteidxcomp()| below for counting composing characters
separately.
When {utf16} is present and TRUE, {nr} is used as the UTF-16
index in the String {expr} instead of as the character index.
The UTF-16 index is the index in the string when it is encoded
with 16-bit words. If the specified UTF-16 index is in the
middle of a character (e.g. in a 4-byte character), then the
byte index of the first byte in the character is returned.
Refer to |string-offset-encoding| for more information.
Example : >vim
echo matchstr(str, ".", byteidx(str, 3))
< will display the fourth character. Another way to do the
same: >vim
let s = strpart(str, byteidx(str, 3))
echo strpart(s, 0, byteidx(s, 1))
< Also see |strgetchar()| and |strcharpart()|.
If there are less than {nr} characters -1 is returned.
If there are exactly {nr} characters the length of the string
in bytes is returned.
See |charidx()| and |utf16idx()| for getting the character and
UTF-16 index respectively from the byte index.
Examples: >vim
echo byteidx('a😊😊', 2) " returns 5
echo byteidx('a😊😊', 2, 1) " returns 1
echo byteidx('a😊😊', 3, 1) " returns 5
<
Parameters: ~
• {expr} (`any`)
• {nr} (`integer`)
• {utf16} (`any?`)
Return: ~
(`integer`)
byteidxcomp({expr}, {nr} [, {utf16}]) *byteidxcomp()*
Like byteidx(), except that a composing character is counted
as a separate character. Example: >vim
let s = 'e' .. nr2char(0x301)
echo byteidx(s, 1)
echo byteidxcomp(s, 1)
echo byteidxcomp(s, 2)
< The first and third echo result in 3 ('e' plus composing
character is 3 bytes), the second echo results in 1 ('e' is
one byte).
Parameters: ~
• {expr} (`any`)
• {nr} (`integer`)
• {utf16} (`any?`)
Return: ~
(`integer`)
call({func}, {arglist} [, {dict}]) *call()* *E699*
Call function {func} with the items in |List| {arglist} as
arguments.
{func} can either be a |Funcref| or the name of a function.
a:firstline and a:lastline are set to the cursor line.
Returns the return value of the called function.
{dict} is for functions with the "dict" attribute. It will be
used to set the local variable "self". |Dictionary-function|
Parameters: ~
• {func} (`any`)
• {arglist} (`any`)
• {dict} (`any?`)
Return: ~
(`any`)
ceil({expr}) *ceil()*
Return the smallest integral value greater than or equal to
{expr} as a |Float| (round up).
{expr} must evaluate to a |Float| or a |Number|.
Examples: >vim
echo ceil(1.456)
< 2.0 >vim
echo ceil(-5.456)
< -5.0 >vim
echo ceil(4.0)
< 4.0
Returns 0.0 if {expr} is not a |Float| or a |Number|.
Parameters: ~
• {expr} (`number`)
Return: ~
(`number`)
chanclose({id} [, {stream}]) *chanclose()*
Close a channel or a specific stream associated with it.
For a job, {stream} can be one of "stdin", "stdout",
"stderr" or "rpc" (closes stdin/stdout for a job started
with `"rpc":v:true`) If {stream} is omitted, all streams
are closed. If the channel is a pty, this will then close the
pty master, sending SIGHUP