Skip to content

FileManager.insertIntoFile method

FileManager › insertIntoFile

Unofficial

Insert text into a file, or into one heading's section of it.

Signature:

insertIntoFile(file: TFile, text: string, position?: 'append' | 'prepend', heading?: string, spacing?: 'auto' | 'inline' | 'newline'): Promise<void>

Parameters:

ParameterTypeDescription
fileTFileThe file to insert into.
textstringThe text to insert.
position?'append' | 'prepend'Where to insert the text. Defaults to 'append'.
heading?stringThe heading whose section receives the text. Throws when the note has no such heading.
spacing?'auto' | 'inline' | 'newline'What separates the inserted text from the existing text: nothing, a line break, or ('auto', the default) a blank line unless one is already there.

Returns: Promise<void> — A promise that resolves when the text is inserted.