Represents an editor that is attached to a {@link TextDocument document}.

Fields

read onlyvisibleRanges:Array<Range>

The current visible ranges in the editor (vertically). This accounts only for vertical scrolling, and not for horizontal scrolling.

@:optionaloptionalread onlyviewColumn:Null<ViewColumn>

The column in which this editor shows. Will be undefined in case this isn't one of the main editors, e.g. an embedded editor, or when the editor column is larger than three.

show(?column:ViewColumn):Void

Deprecated: "Use `window.showTextDocument` instead."
Deprecated:

Use {

Show the text editor.

@link window.showTextDocument} instead.

@link ViewColumn column} in which to show this editor. This method shows unexpected behavior and will be removed in the next major update.

Parameters:

column

The {

setDecorations(decorationType:TextEditorDecorationType, rangesOrOptions:EitherType<ReadOnlyArray<Range>, ReadOnlyArray<DecorationOptions>>):Void

Adds a set of decorations to the text editor. If a set of decorations already exists with the given {@link TextEditorDecorationType decoration type}, they will be replaced. If rangesOrOptions is empty, the existing decorations with the given {@link TextEditorDecorationType decoration type} will be removed.

@link window.createTextEditorDecorationType createTextEditorDecorationType}.

@link Range ranges} or more detailed {@link DecorationOptions options}.

Parameters:

decorationType

A decoration type.

rangesOrOptions

Either {

See also:

  • {

selections:Array<Selection>

The selections in this text editor. The primary selection is always at index 0.

selection:Selection

The primary selection on this text editor. Shorthand for TextEditor.selections[0].

revealRange(range:Range, ?revealType:TextEditorRevealType):Void

Scroll as indicated by revealType in order to reveal the given range.

Parameters:

range

A range.

revealType

The scrolling strategy for revealing range.

options:TextEditorOptions

Text editor options.

insertSnippet(snippet:SnippetString, ?location:EitherType<Position, EitherType<Range, EitherType<ReadOnlyArray<Position>, ReadOnlyArray<Range>>>>, ?options:{undoStopBefore:Bool, undoStopAfter:Bool}):Thenable<Bool>

Insert a {@link SnippetString snippet} and put the editor into snippet mode. "Snippet mode" means the editor adds placeholders and additional cursors so that the user can complete or accept the snippet.

Parameters:

snippet

The snippet to insert in this edit.

location

Position or range at which to insert the snippet, defaults to the current editor selection or selections.

options

The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.

Returns:

A promise that resolves with a value indicating if the snippet could be inserted. Note that the promise does not signal that the snippet is completely filled-in or accepted.

hide():Void

Deprecated: "Use the command `workbench.action.closeActiveEditor` instead."
Deprecated:

Use the command workbench.action.closeActiveEditor instead. This method shows unexpected behavior and will be removed in the next major update.

Hide the text editor.

edit(callback:TextEditorEdit ‑> Void, ?options:{undoStopBefore:Bool, undoStopAfter:Bool}):Thenable<Bool>

Perform an edit on the document associated with this text editor.

The given callback-function is invoked with an {@link TextEditorEdit edit-builder} which must be used to make edits. Note that the edit-builder is only valid while the callback executes.

@link TextEditorEdit edit-builder}.

Parameters:

callback

A function which can create edits using an {

options

The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.

Returns:

A promise that resolves with a value indicating if the edits could be applied.

read onlydocument:TextDocument

The document associated with this text editor. The document will be the same for the entire lifetime of this text editor.