Skip to content

Function.indent

github-actions[bot] edited this page Nov 18, 2026 · 13 revisions

umt / indent

Function: indent()

indent(string_, count, char?): string

Defined in: String/indent.ts:13

Prefixes every non-empty line with count repetitions of char. Empty lines are left untouched, which makes this the inverse of dedent. A negative count is treated as 0.

Parameters

string_

string

The string to indent

count

number

The number of times char is repeated per line

char?

string = " "

The indentation unit (default: " ")

Returns

string

The indented string

Example

indent("line1\nline2", 2); // "  line1\n  line2"
indent("a\n\nb", 1, "\t"); // "\ta\n\n\tb"

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally