import { fn } from "https://deno.land/x/ddu_vim@v4.0.0/deps.ts";
const { strpart } = fn;
The result is a String, which is part of {src}, starting from
byte {start}, with the byte length {len}.
When {chars} is present and TRUE then {len} is the number of
characters positions (composing characters are not counted
separately, thus "1" means one base character and any
following composing characters).
To count {start} as characters instead of bytes use
strcharpart()
.
When bytes are selected which do not exist, this doesn't result in an error, the bytes are simply omitted. If {len} is missing, the copy continues from {start} till the end of the {src}.
strpart("abcdefg", 3, 2) == "de"
strpart("abcdefg", -2, 4) == "ab"
strpart("abcdefg", 5, 4) == "fg"
strpart("abcdefg", 3) == "defg"
Note: To get the first character, {start} must be 0. For example, to get the character under the cursor:
strpart(getline("."), col(".") - 1, 1, v:true)
Returns an empty string on error.
Can also be used as a method
:
GetText()->strpart(5)