Skip to main content
Module

x/ddc_vim/deps.ts>fn.byteidx

Dark deno-powered completion framework for neovim/Vim8
Go to Latest
function fn.byteidx
import { fn } from "https://deno.land/x/ddc_vim@v2.3.0/deps.ts";
const { byteidx } = fn;

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. Example : echo matchstr(str, ".", byteidx(str, 3)) will display the fourth character. Another way to do the same: 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. Can also be used as a |method|: GetName()->byteidx(idx)

Parameters

denops: Denops
expr: unknown
nr: unknown

Returns

Promise<unknown>