Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/function/mod.ts>tr

๐Ÿ“š Standard module for denops.vim
Go to Latest
function tr
import { tr } from "https://deno.land/x/denops_std@v5.0.2/function/mod.ts";

The result is a copy of the {src} string with all characters which appear in {fromstr} replaced by the character in that position in the {tostr} string. Thus the first character in {fromstr} is translated into the first character in {tostr} and so on. Exactly like the unix "tr" command. This code also deals with multibyte characters properly.

Returns an empty string on error.

Examples:

echo tr("hello there", "ht", "HT")

returns "Hello THere"

echo tr("<blob>", "<>", "{}")

returns "{blob}"

Can also be used as a method:

GetText()->tr(from, to)

Parameters

denops: Denops
src: unknown
fromstr: unknown
tostr: unknown

Returns

Promise<string>