Skip to content

Editor

new Editor(container, options?): Editor

HTMLElement

EditorOptions

Editor

addPlugin(plugin): EditorDisposable

EditorPlugin

EditorDisposable


applyEdit(edit, tokens, textSnapshot): void

textSnapshot is the text after edit; a detached view renders it. On a buffer session the edit goes through the session, which supplies its own.

TextEdit

EditorTokenInput

TextSnapshot

void


attachSession(session, options?): void

DocumentSession

EditorSessionOptions

void


authorEdits(author): EditorDisposable

DocumentEditAuthor

EditorDisposable


captureSnapshot(options): DocumentPaintCapture

"document"

DocumentPaintCapture

captureSnapshot(options?): any

"viewport"

any


clear(): void

void


clearDocument(): void

void


closeFind(): boolean

boolean


cursorRedo(): boolean

boolean


cursorUndo(): boolean

Returns the carets, and the view, to where they were before the last caret move.

boolean


detachSession(): void

void


dispatchCommand(command, context?): boolean

EditorAnyCommandId

EditorCommandContext

boolean


dispose(): void

void


edit(editOrEdits, options?): void

EditorEditInput

DocumentSessionApplyEditsOptions

void


findNext(): boolean

boolean


findPrevious(): boolean

boolean


focus(): void

void


fold(offset?): boolean

number

boolean


foldAll(): boolean

boolean


getBufferSession(): EditorBufferSession | null

EditorBufferSession | null


getCommandDeclarations(): readonly (EditorCommandDeclaration<"find" | "insertNewlineAndIndent" | "copy" | "cut" | "paste" | "markdown.indentListItem" | "markdown.outdentListItem" | "lsp.rename.accept" | "lsp.rename.cancel" | "tooltip.hide" | "tooltip.scrollUp" | "tooltip.scrollDown" | "tooltip.pageUp" | "tooltip.pageDown" | "tooltip.scrollStart" | "tooltip.scrollEnd" | "markdown.openLink" | "markdown.bold" | "markdown.italic" | "markdown.strikethrough" | "markdown.code" | "markdown.link" | "markdown.heading" | "markdown.bulletList" | "markdown.orderedList" | "markdown.taskList" | "markdown.toggleTask" | "markdown.quote" | "markdown.codeBlock" | "undo" | "redo" | "jumpBack" | "jumpForward" | "cursorUndo" | "cursorRedo" | "findReplace" | "findNext" | "findPrevious" | "editor.action.goToDefinition" | "editor.action.goToReferences" | "editor.action.peekDefinition" | "editor.action.revealDefinitionAside" | "editor.action.goToImplementation" | "editor.action.goToTypeDefinition" | "editor.action.showHover" | "editor.action.marker.next" | "editor.action.marker.prev" | "merge-conflict.accept.current" | "merge-conflict.accept.incoming" | "merge-conflict.accept.both" | "merge-conflict.accept.selection" | "merge-conflict.accept.all-current" | "merge-conflict.accept.all-incoming" | "merge-conflict.accept.all-both" | "merge-conflict.next" | "merge-conflict.previous" | "merge-conflict.compare" | "closeFind" | "toggleFindCaseSensitive" | "toggleFindWholeWord" | "toggleFindRegex" | "toggleFindInSelection" | "togglePreserveCase" | "replaceOne" | "replaceAll" | "selectAllMatches" | "selectAll" | "editor.action.smartSelect.expand" | "editor.action.smartSelect.shrink" | "addNextOccurrence" | "clearSecondarySelections" | "editor.action.insertCursorAbove" | "editor.action.insertCursorBelow" | "editor.action.selectHighlights" | "editor.action.changeAll" | "editor.action.jumpToBracket" | "editor.action.toggleWordWrap" | "editor.action.toggleTabFocusMode" | "editor.action.formatDocument" | "editor.action.rename" | "editor.action.autoFix" | "editor.action.inlineSuggest.commit" | "editor.action.inlineSuggest.acceptNextWord" | "editor.action.triggerSuggest" | "selectNextSuggestion" | "selectPrevSuggestion" | "selectNextPageSuggestion" | "selectPrevPageSuggestion" | "acceptSelectedSuggestion" | "hideSuggestWidget" | "closeParameterHints" | "showNextParameterHint" | "showPrevParameterHint" | "editor.action.moveSelectionToNextFindMatch" | "editor.fold" | "editor.unfold" | "editor.foldRecursively" | "editor.unfoldRecursively" | "editor.foldAll" | "editor.unfoldAll" | "editor.foldLevel1" | "editor.foldLevel2" | "editor.foldLevel3" | "editor.foldLevel4" | "editor.foldLevel5" | "editor.foldLevel6" | "editor.foldLevel7" | "editor.createFoldingRangeFromSelection" | "editor.removeManualFoldingRanges" | "deleteBackward" | "deleteForward" | "deleteWordLeft" | "deleteWordRight" | "deleteWordPartLeft" | "deleteWordPartRight" | "editor.action.commentLine" | "editor.action.blockComment" | "editor.action.indentLines" | "editor.action.outdentLines" | "editor.action.reindentlines" | "editor.action.reindentselectedlines" | "editor.action.deleteLines" | "editor.action.copyLinesUpAction" | "editor.action.copyLinesDownAction" | "editor.action.moveLinesUpAction" | "editor.action.moveLinesDownAction" | "editor.action.insertLineBefore" | "editor.action.insertLineAfter" | "editor.action.trimTrailingWhitespace" | "editor.action.sortLinesAscending" | "editor.action.sortLinesDescending" | "editor.action.joinLines" | "editor.action.duplicateSelection" | "editor.action.transformToUppercase" | "editor.action.transformToLowercase" | "editor.action.transformToTitlecase" | "cursorWordPartLeft" | "cursorWordPartRight" | "cursorWordPartLeftSelect" | "cursorWordPartRightSelect" | "indentSelection" | "outdentSelection" | "cursorLeft" | "cursorRight" | "cursorUp" | "cursorDown" | "selectLeft" | "selectRight" | "selectUp" | "selectDown" | "cursorWordLeft" | "cursorWordRight" | "selectWordLeft" | "selectWordRight" | "cursorLineStart" | "cursorLineEnd" | "selectLineStart" | "selectLineEnd" | "cursorPageUp" | "cursorPageDown" | "selectPageUp" | "selectPageDown" | "cursorDocumentStart" | "cursorDocumentEnd" | "selectDocumentStart" | "selectDocumentEnd" | "cursorColumnSelectLeft" | "cursorColumnSelectRight" | "cursorColumnSelectUp" | "cursorColumnSelectDown" | "cursorColumnSelectPageUp" | "cursorColumnSelectPageDown"> | EditorContributedCommandDeclaration)[]

The commands this editor knows: every built-in, then those its plugins contribute.

readonly (EditorCommandDeclaration<"find" | "insertNewlineAndIndent" | "copy" | "cut" | "paste" | "markdown.indentListItem" | "markdown.outdentListItem" | "lsp.rename.accept" | "lsp.rename.cancel" | "tooltip.hide" | "tooltip.scrollUp" | "tooltip.scrollDown" | "tooltip.pageUp" | "tooltip.pageDown" | "tooltip.scrollStart" | "tooltip.scrollEnd" | "markdown.openLink" | "markdown.bold" | "markdown.italic" | "markdown.strikethrough" | "markdown.code" | "markdown.link" | "markdown.heading" | "markdown.bulletList" | "markdown.orderedList" | "markdown.taskList" | "markdown.toggleTask" | "markdown.quote" | "markdown.codeBlock" | "undo" | "redo" | "jumpBack" | "jumpForward" | "cursorUndo" | "cursorRedo" | "findReplace" | "findNext" | "findPrevious" | "editor.action.goToDefinition" | "editor.action.goToReferences" | "editor.action.peekDefinition" | "editor.action.revealDefinitionAside" | "editor.action.goToImplementation" | "editor.action.goToTypeDefinition" | "editor.action.showHover" | "editor.action.marker.next" | "editor.action.marker.prev" | "merge-conflict.accept.current" | "merge-conflict.accept.incoming" | "merge-conflict.accept.both" | "merge-conflict.accept.selection" | "merge-conflict.accept.all-current" | "merge-conflict.accept.all-incoming" | "merge-conflict.accept.all-both" | "merge-conflict.next" | "merge-conflict.previous" | "merge-conflict.compare" | "closeFind" | "toggleFindCaseSensitive" | "toggleFindWholeWord" | "toggleFindRegex" | "toggleFindInSelection" | "togglePreserveCase" | "replaceOne" | "replaceAll" | "selectAllMatches" | "selectAll" | "editor.action.smartSelect.expand" | "editor.action.smartSelect.shrink" | "addNextOccurrence" | "clearSecondarySelections" | "editor.action.insertCursorAbove" | "editor.action.insertCursorBelow" | "editor.action.selectHighlights" | "editor.action.changeAll" | "editor.action.jumpToBracket" | "editor.action.toggleWordWrap" | "editor.action.toggleTabFocusMode" | "editor.action.formatDocument" | "editor.action.rename" | "editor.action.autoFix" | "editor.action.inlineSuggest.commit" | "editor.action.inlineSuggest.acceptNextWord" | "editor.action.triggerSuggest" | "selectNextSuggestion" | "selectPrevSuggestion" | "selectNextPageSuggestion" | "selectPrevPageSuggestion" | "acceptSelectedSuggestion" | "hideSuggestWidget" | "closeParameterHints" | "showNextParameterHint" | "showPrevParameterHint" | "editor.action.moveSelectionToNextFindMatch" | "editor.fold" | "editor.unfold" | "editor.foldRecursively" | "editor.unfoldRecursively" | "editor.foldAll" | "editor.unfoldAll" | "editor.foldLevel1" | "editor.foldLevel2" | "editor.foldLevel3" | "editor.foldLevel4" | "editor.foldLevel5" | "editor.foldLevel6" | "editor.foldLevel7" | "editor.createFoldingRangeFromSelection" | "editor.removeManualFoldingRanges" | "deleteBackward" | "deleteForward" | "deleteWordLeft" | "deleteWordRight" | "deleteWordPartLeft" | "deleteWordPartRight" | "editor.action.commentLine" | "editor.action.blockComment" | "editor.action.indentLines" | "editor.action.outdentLines" | "editor.action.reindentlines" | "editor.action.reindentselectedlines" | "editor.action.deleteLines" | "editor.action.copyLinesUpAction" | "editor.action.copyLinesDownAction" | "editor.action.moveLinesUpAction" | "editor.action.moveLinesDownAction" | "editor.action.insertLineBefore" | "editor.action.insertLineAfter" | "editor.action.trimTrailingWhitespace" | "editor.action.sortLinesAscending" | "editor.action.sortLinesDescending" | "editor.action.joinLines" | "editor.action.duplicateSelection" | "editor.action.transformToUppercase" | "editor.action.transformToLowercase" | "editor.action.transformToTitlecase" | "cursorWordPartLeft" | "cursorWordPartRight" | "cursorWordPartLeftSelect" | "cursorWordPartRightSelect" | "indentSelection" | "outdentSelection" | "cursorLeft" | "cursorRight" | "cursorUp" | "cursorDown" | "selectLeft" | "selectRight" | "selectUp" | "selectDown" | "cursorWordLeft" | "cursorWordRight" | "selectWordLeft" | "selectWordRight" | "cursorLineStart" | "cursorLineEnd" | "selectLineStart" | "selectLineEnd" | "cursorPageUp" | "cursorPageDown" | "selectPageUp" | "selectPageDown" | "cursorDocumentStart" | "cursorDocumentEnd" | "selectDocumentStart" | "selectDocumentEnd" | "cursorColumnSelectLeft" | "cursorColumnSelectRight" | "cursorColumnSelectUp" | "cursorColumnSelectDown" | "cursorColumnSelectPageUp" | "cursorColumnSelectPageDown"> | EditorContributedCommandDeclaration)[]


getContentHeight(): number

number


getFeature<T>(token): T | null

A capability a plugin registered on this editor, such as spellcheck; null while none has.

T

EditorCapabilityToken<T>

T | null


getHotkeysHost(): EditorHotkeysHost

The dispatcher and focus node that own this editor’s keyboard commands.

EditorHotkeysHost


getInputElement(): HTMLElement

HTMLElement


getKeymapContext(): EditorKeymapContext

EditorKeymapContext


getMergeConflicts(): readonly MergeConflictRegion[]

readonly MergeConflictRegion[]


getPresentationState(): "provisional" | "live" | "empty"

"provisional" | "live" | "empty"


getScrollPosition(): Required<EditorScrollPosition>

Required<EditorScrollPosition>


getSelections(): readonly EditorResolvedSelection[]

Every selection as document offsets, primary first.

readonly EditorResolvedSelection[]


getState(): EditorState

EditorState


getSyntaxRecords(): EditorSyntaxRecords | null

Parsed records for this exact text revision; absent while analysis catches up.

EditorSyntaxRecords | null


getTextSnapshot(): TextSnapshot

TextSnapshot


isTabMovesFocusEnabled(): boolean

boolean


isWordWrapEnabled(): boolean

boolean


jumpBack(): boolean

boolean


jumpForward(): boolean

boolean


jumpTo(anchor, head?, cause?): void

number

number

JumpCause

void


markerAtPoint(clientX, clientY): EditorMarkerHit | null

number

number

EditorMarkerHit | null


materializeFullText(): string

O(document length) on every call, never cached; save and export are what it is for.

string


onDidChangeContentHeight(listener): EditorDisposable

Called with the rows’ total height in pixels whenever it changes: lines added or removed, wrap reflowing, the font changing. A host that grows with its text sizes itself from this.

(height) => void

EditorDisposable


onDidScroll(listener): EditorDisposable

Called with the position after it changes, from a gesture, a programmatic move or a clamp. The virtualizer has already folded the scroll in, so the position is current, and nothing throttles it.

(position) => void

EditorDisposable


onDidTransaction(listener): EditorDisposable

Each logical edit, before view updates can coalesce it. The registration survives document swaps.

(event) => void

EditorDisposable


openDocument(document): void

EditorOpenDocumentOptions

void


openFind(): boolean

boolean


openFindReplace(): boolean

boolean


reconcile(base, batches, options): void

PieceTableTreeSnapshot

readonly readonly TextEdit[][]

DocumentSessionReconcileOptions

void


registerKeymapNode(options): object

EditorKeymapNodeOptions

object

dispose: () => void

void


removePlugin(plugin): boolean

EditorPlugin

boolean


replaceAll(): boolean

boolean


replaceOne(): boolean

boolean


resolveMergeConflict(index, resolution): boolean

number

MergeConflictResolution

boolean


revealMergeConflict(index): boolean

number

boolean


rowAtPoint(clientX, clientY): EditorPointHit | null

number

number

EditorPointHit | null


runInOperation<T>(run): T

Runs run as a single mutating pass. Whatever it changes, the caret is revealed once, the DOM selection is written back once and listeners hear once, at the end — so a sequence of edits costs one visual update instead of one each. Calls made from inside a pass join it rather than opening another.

T

() => T

T


selectAllMatches(): boolean

boolean


setContent(text): void

On a buffer session this replaces the buffer’s text as one undoable edit every view sees.

string

void


setDetectIndentation(enabled): void

boolean

void


setDocument(document): void

EditorDocument

void


setEditability(editability): void

EditorEditability

void


setFolding(enabled): void

boolean

void


setFoldMap(foldMap): void

FoldMap | null

void


setFontFamily(fontFamily): void

A CSS font-family list; undefined hands the face back to the stylesheet.

string | undefined

void


setFontSize(fontSize): void

Undefined hands the size back to the stylesheet.

number | undefined

void


setGutterLeadingInset(inset): void

Empty pixels before the first gutter lane; row decorations tint them. 0 removes the inset.

number

void


setGutterScroll(mode): void

Switch all gutter lanes between the viewport edge and the horizontally scrolling text.

NonNullable<EditorGutterScroll | undefined>

void


setHiddenCharacters(mode): void

HiddenCharactersMode

void


setInlineMap(inlineMap): void

Installs the inline replacements this document renders instead of parts of its own text — the entry point a markdown live-preview view drives. Passing null restores raw buffer text.

InlineMap | null

void


setInlineReplacementProvider(provider, options?): void

Registers a provider that turns the document’s syntax captures into inline replacements. The map is rebuilt whenever fresh captures land, so a markdown view stays in step with the parse without the host scheduling anything itself. Passing null removes the transform.

EditorInlineReplacementProvider | null

EditorInlineReplacementProviderOptions

void


setInlineSuggestion(edit): boolean

Offers an inline suggestion, drawn in front of the reader as the part of it the document does not already hold. Passing null takes back whatever is showing.

TextEdit | null

boolean


setKeymap(keymap): void

EditorKeymapOptions | undefined

void


setLineHeight(lineHeight): void

number

void


setPlugins(plugins): void

readonly EditorPlugin[]

void


setPresentationReady(ready): void

boolean

void


setRangeDecorations(decorations): void

readonly EditorRangeDecoration[]

void


setRowDecorations(decorations): void

ReadonlyMap<number, VirtualizedTextRowDecoration>

void


setRowGap(rowGap): void

number

void


setScrollMode(scrollMode): void

VirtualizedTextViewScrollMode | undefined

void


setScrollPosition(scrollPosition): void

EditorScrollPosition

void


setSelection(anchor, head?, options?): void

number

number

EditorSetSelectionOptions

void


setSnapshot(snapshot, documentKey): void

string | null

string | null

void


setSuspiciousCharacters(options): void

EditorSuspiciousCharactersOptions | undefined

void


setSyntaxFolds(folds): void

readonly FoldRange[]

void


setTabMovesFocus(enabled): boolean

Gives Tab back to the page, or takes it for indentation again. Returns the state in effect afterwards. Nothing is announced from here: a host writing its own controls says what it did in its own words, and the key that toggles this from inside the editor speaks for itself.

boolean

boolean


setTabSize(tabSize): void

Columns a tab spans, and the fallback the open document’s indentation is guessed against, so a document that gave no sign of its own follows the new width. Undefined is the default, 4.

number | undefined

void


setText(text, options?): void

string

EditorSetTextOptions

void


setTheme(theme): void

EditorTheme | null | undefined

void


setTokens(tokens): void

EditorTokenInput

void


setWordWrap(enabled): boolean

Turns soft wrap on or off. Returns the state actually in effect afterwards.

boolean

boolean


syncText(text, options?): void

string

EditorSetTextOptions

void


textOffsetFromPoint(clientX, clientY): number | null

number

number

number | null


toggleFold(offset?): boolean

number

boolean


unfold(offset?): boolean

number

boolean


unfoldAll(): boolean

boolean