Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents an editor that is attached to a document.

层级

  • TextEditor

索引

Properties(6)

Readonly document

document: TextDocument

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

selection

selection: Selection

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

selections

selections: Selection[]

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

Readonly visibleRanges

visibleRanges: Range[]

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

options

Text editor options.

Optional Readonly viewColumn

viewColumn: 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.

Methods(6)

edit

  • edit(callback: (editBuilder: TextEditorEdit) => void, options?: { undoStopBefore: boolean; undoStopAfter: boolean }): Thenable<boolean>
  • Perform an edit on the document associated with this text editor.

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

    Parameters

    • callback: (editBuilder: TextEditorEdit) => void

      A function which can create edits using an edit-builder.

    • Optional options: { undoStopBefore: boolean; undoStopAfter: boolean }

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

      • undoStopBefore: boolean
      • undoStopAfter: boolean

    Returns Thenable<boolean>

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

insertSnippet

  • Insert a 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: SnippetString

      The snippet to insert in this edit.

    • Optional location: Range | Position | readonly Range[] | readonly Position[]

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

    • Optional options: { undoStopBefore: boolean; undoStopAfter: boolean }

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

      • undoStopBefore: boolean
      • undoStopAfter: boolean

    Returns Thenable<boolean>

    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.

setDecorations

revealRange

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

    Parameters

    Returns void

show

  • Show the text editor.

    deprecated

    Use window.showTextDocument instead.

    Parameters

    • Optional column: ViewColumn

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

    Returns void

hide

  • hide(): void
  • Hide the text editor.

    deprecated

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

    Returns void

友链:VS Code 中文文档 | VS Code 官网文档 | VS Code 扩展市场

Generated by TypeDoc. Maintained by 洛竹