Skip to content

Editor.processLines method

Editor › processLines

Official

Process lines.

Signature:

processLines(read: (line: number, lineText: string) => T | null, write: (line: number, lineText: string, value: T | null) => void | EditorChange, ignoreEmpty?: boolean | undefined): void

Parameters:

ParameterTypeDescription
read(line: number, lineText: string) => T | nullComputes a value for a line.
write(line: number, lineText: string, value: T | null) => void | EditorChangeComputes the change for a line, given its value. Return nothing to leave the line unchanged.
ignoreEmpty?boolean | undefinedWhether to skip empty lines when multiple lines are selected.

Returns: void

Since: 0.13.26

Example:

editor.processLines(
(line, lineText) => lineText.startsWith('- '),
(line, lineText, isListItem) => isListItem ? undefined : { from: { line, ch: 0 }, text: '- ' },
);