Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>fn.stridx

Dark deno-powered completion framework for neovim/Vim
Go to Latest
function fn.stridx
import { fn } from "https://deno.land/x/ddc_vim@v4.1.0/deps.ts";
const { stridx } = fn;

The result is a Number, which gives the byte index in {haystack} of the first occurrence of the String {needle}. If {start} is specified, the search starts at index {start}. This can be used to find a second match:

:let colon1 = stridx(line, ":")
:let colon2 = stridx(line, ":", colon1 + 1)

The search is done case-sensitive. For pattern searches use match(). -1 is returned if the {needle} does not occur in {haystack}. See also strridx(). Examples:

:echo stridx("An Example", "Example")      3
:echo stridx("Starting point", "Start")    0
:echo stridx("Starting point", "start")   -1

stridx() works similar to the C function strstr(). When used with a single character it works similar to strchr().

Can also be used as a method:

GetHaystack()->stridx(needle)

Parameters

denops: Denops
haystack: unknown
needle: unknown
optional
start: unknown

Returns

Promise<number>