Ace API Reference
    Preparing search index...

    Class Editor

    The main entry point into the Ace functionality.

    The Editor manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen.

    Event sessions dealing with the mouse and keyboard are bubbled up from Document to the Editor, which decides what to do with them.

    Hierarchy

    • EditorMultiSelectProperties
    • OptionsProvider<Ace.EditorOptions>
    • EventEmitter<Ace.EditorEvents>
    • CodeLenseEditorExtension
    • ElasticTabstopsEditorExtension
    • TextareaEditorExtension
    • PromptEditorExtension
    • OptionsEditorExtension
      • Editor
    Index

    Constructors

    Properties

    Accessors

    Methods

    addEventListener applyComposition autoIndent blockIndent blockOutdent blur centerSelection clearSelection copyLinesDown copyLinesUp destroy duplicateSelection endOperation execCommand find findLinkAt findNext findPrevious focus getAnimatedScroll getBehavioursEnabled getCopyText getCursorPosition getCursorPositionScreen getDisplayIndentGuides getDragDelay getFadeFoldWidgets getFirstVisibleRow getFontSize getHighlightActiveLine getHighlightGutterLine getHighlightIndentGuides getHighlightSelectedWord getKeyboardHandler getLastSearchOptions getLastVisibleRow getNumberAt getOption getOptions getOverwrite getPrintMarginColumn getReadOnly getScrollSpeed getSelection getSelectionRange getSelectionStyle getSession getShowFoldWidgets getShowInvisibles getShowPrintMargin getTheme getValue getWrapBehavioursEnabled gotoLine gotoPageDown gotoPageUp indent insert isFocused isRowFullyVisible isRowVisible jumpToMatching modifyNumber moveCursorTo moveCursorToPosition moveLinesDown moveLinesUp moveText navigateDown navigateFileEnd navigateFileStart navigateLeft navigateLineEnd navigateLineStart navigateRight navigateTo navigateUp navigateWordLeft navigateWordRight off on once onEndOperation onStartOperation openLink prompt redo remove removeAllListeners removeDefaultHandler removeEventListener removeGhostText removeLines removeListener removeToLineEnd removeToLineStart removeWordLeft removeWordRight replace replaceAll resize revealRange scrollPageDown scrollPageUp scrollToLine scrollToRow selectAll selectPageDown selectPageUp setAnimatedScroll setAutoScrollEditorIntoView setBehavioursEnabled setDefaultHandler setDisplayIndentGuides setDragDelay setFadeFoldWidgets setFontSize setGhostText setHighlightActiveLine setHighlightGutterLine setHighlightIndentGuides setHighlightSelectedWord setKeyboardHandler setOption setOptions setOverwrite setPrintMarginColumn setReadOnly setScrollSpeed setSelectionStyle setSession setShowFoldWidgets setShowInvisibles setShowPrintMargin setStyle setTheme setValue setWrapBehavioursEnabled sortLines splitLine startOperation toggleBlockComment toggleCommentLines toggleOverwrite toggleWord toLowerCase toUpperCase transposeLetters undo unsetStyle

    Constructors

    Properties

    addSelectionMarker: (
        orientedRange: Range & { marker?: any },
    ) => Range & { marker?: any }

    Adds the selection and cursor.

    Type declaration

      • (orientedRange: Range & { marker?: any }): Range & { marker?: any }
      • Parameters

        • orientedRange: Range & { marker?: any }

          A range containing a cursor

        Returns Range & { marker?: any }

    alignCursors: () => void

    Aligns the cursors or selected text.

    cmdLine?: Editor
    codeLensProviders?: CodeLenseProvider[]
    commands: CommandManager
    completer?: Autocomplete | InlineAutocomplete
    completers: Completer[]
    container: HTMLElement & { env?: any; value?: any }
    curOp: {}
    destroyed: boolean

    true if editor is destroyed

    elasticTabstops?: ElasticTabstopsLite
    env?: any
    exitMultiSelectMode: () => void

    Removes all the selections except the last added one.

    findAll: (
        needle?: string,
        options?: Partial<Ace.SearchOptions>,
        additive?: boolean,
    ) => number

    Finds and selects all the occurrences of needle.

    Type declaration

      • (
            needle?: string,
            options?: Partial<Ace.SearchOptions>,
            additive?: boolean,
        ): number
      • Parameters

        • Optionalneedle: string

          The text to find

        • Optionaloptions: Partial<Ace.SearchOptions>

          The search options

        • Optionaladditive: boolean

          keeps

        Returns number

        The cumulative count of all found matches

    forEachSelection: (cmd: Object, args?: string, options?: Object) => void

    Executes a command for each selection range.

    Type declaration

      • (cmd: Object, args?: string, options?: Object): void
      • Parameters

        • cmd: Object

          The command to execute

        • Optionalargs: string

          Any arguments for the command

        • Optionaloptions: Object

        Returns void

    getSelectedText: () => string
    id: string
    inMultiSelectMode?: boolean
    inVirtualSelectionMode: boolean
    keyBinding: KeyBinding
    mergeNextCommand: boolean
    multiSelect?: any
    previousCommand: any
    prevOp: {}
    removeSelectionMarker: (range: Range & { marker?: any }) => void

    Removes the selection marker.

    Type declaration

      • (range: Range & { marker?: any }): void
      • Parameters

        • range: Range & { marker?: any }

          The selection range added with [[Editor.addSelectionMarker addSelectionMarker()]].

        Returns void

    removeSelectionMarkers: (ranges: (Range & { marker?: any })[]) => void
    renderer: VirtualRenderer
    searchBox?: SearchBox
    selection: Selection
    selectMore: (dir: number, skip?: boolean, stopAtFirst?: boolean) => void

    Finds the next occurrence of text in an active selection and adds it to the selections.

    Type declaration

      • (dir: number, skip?: boolean, stopAtFirst?: boolean): void
      • Parameters

        • dir: number

          The direction of lines to select: -1 for up, 1 for down

        • Optionalskip: boolean

          If true, removes the active selection range

        • OptionalstopAtFirst: boolean

        Returns void

    selectMoreLines: (dir: number, skip?: boolean) => void

    Adds a cursor above or below the active cursor.

    Type declaration

      • (dir: number, skip?: boolean): void
      • Parameters

        • dir: number

          The direction of lines to select: -1 for up, 1 for down

        • Optionalskip: boolean

          If true, removes the active selection range

        Returns void

    sequenceStartTime: number
    session: EditSession
    setDisplaySettings?: (settings: any) => void
    showKeyboardShortcuts?: () => void
    showSettingsMenu?: () => void
    textInput: TextInput
    transposeSelections: (dir: number) => void

    Transposes the selected ranges.

    Type declaration

      • (dir: number): void
      • Parameters

        • dir: number

          The direction to rotate selections

        Returns void

    updateSelectionMarkers: () => void

    Updates the cursor and marker layers.

    widgetManager?: LineWidgets

    Accessors

    Methods

    • Parameters

      • Optionaltext: string
      • Optionalcomposition: any

      Returns void

    • Copies all the selected lines down one row.

      Returns void

    • Attempts to find needle within the document. For more information on options, see [[Search Search]].

      Parameters

      • needle: any

        The text to search for (optional)

      • Optionaloptions: Partial<SearchOptions>

        An object defining various search properties

      • Optionalanimate: boolean

        If true animate scrolling

      Returns false | Range

    • Finds link at defined {row} and {column}

      Parameters

      • row: any
      • column: any

      Returns string

    • Performs another search for needle in the document. For more information on options, see [[Search Search]].

      Parameters

      • Optionaloptions: Partial<SearchOptions>

        search options

      • Optionalanimate: boolean

        If true animate scrolling

      Returns void

    • Performs a search for needle backwards. For more information on options, see [[Search Search]].

      Parameters

      • Optionaloptions: Partial<SearchOptions>

        search options

      • Optionalanimate: boolean

        If true animate scrolling

      Returns void

    • Returns true if the behaviors are currently enabled. {:BehaviorsDef}

      Returns boolean

    • Gets the current position of the cursor.

      Returns Ace.Point

      An object that looks something like this:

      { row: currRow, column: currCol }
      
    • {:VirtualRenderer.getFirstVisibleRow}

      Returns number

    • Gets the current font size of the editor text.

      Returns string | number

    • Returns true if current lines are always highlighted.

      Returns boolean

    • Returns true if currently highlighted words are to be highlighted.

      Returns boolean

    • {:Search.getOptions} For more information on options, see [[Search Search]].

      Returns Partial<SearchOptions>

    • {:VirtualRenderer.getLastVisibleRow}

      Returns number

    • Works like [[EditSession.getTokenAt]], except it returns a number.

      Parameters

      • row: any
      • column: any

      Returns any

    • Returns true if overwrites are enabled; false otherwise.

      Returns boolean

    • Returns the column number of where the print margin is.

      Returns number

    • Returns the value indicating how fast the mouse scroll speed is (in milliseconds).

      Returns number

    • Returns the currently highlighted selection.

      Returns Selection

      The selection object

    • Returns the current selection style.

      Returns "line" | "text" | "fullLine" | "screenLine"

    • Returns true if invisible characters are being shown.

      Returns boolean

    • {:VirtualRenderer.getTheme}

      Returns string

      The set theme

    • Returns the current session's content.

      Returns string

    • Returns true if the wrapping behaviors are currently enabled.

      Returns boolean

    • Moves the cursor to the specified line number, and also into the indicated column.

      Parameters

      • lineNumber: number

        The line number to go to

      • Optionalcolumn: number

        A column number to go to

      • Optionalanimate: boolean

        If true animates scolling

      Returns void

    • Shifts the document to wherever "page down" is, as well as moving the cursor position.

      Returns void

    • Shifts the document to wherever "page up" is, as well as moving the cursor position.

      Returns void

    • Inserts an indentation into the current cursor position or indents the selected lines.

      Returns void

    • Inserts text into wherever the cursor is pointing.

      Parameters

      • text: string

        The new text to add

      • Optionalpasted: boolean

      Returns void

    • Indicates if the entire row is currently visible on the screen.

      Parameters

      • row: number

        The row to check

      Returns boolean

    • Indicates if the row is currently visible on the screen.

      Parameters

      • row: number

        The row to check

      Returns boolean

    • Moves the cursor's row and column to the next matching bracket or HTML tag.

      Parameters

      • Optionalselect: boolean
      • Optionalexpand: boolean

      Returns void

    • If the character before the cursor is a number, this functions changes its value by amount.

      Parameters

      • amount: number

        The value to change the numeral by (can be negative to decrease value)

      Returns void

    • Moves the cursor to the specified row and column. Note that this does not de-select the current selection.

      Parameters

      • row: number

        The new row number

      • column: number

        The new column number

      Returns void

    • Moves the cursor to the position indicated by pos.row and pos.column.

      Parameters

      • pos: Ace.Point

        An object with two properties, row and column

      Returns void

    • Shifts all the selected lines down one row.

      Returns void

    • Shifts all the selected lines up one row.

      Returns void

    • Moves a range of text from the given range to the given position. toPosition is an object that looks like this:

         { row: newRowLocation, column: newColumnLocation }
      

      Parameters

      • range: Range

        The range of text you want moved within the document

      • toPosition: Ace.Point

        The location (row and column) where you want to move the text to

      • Optionalcopy: boolean

      Returns Range

      The new range where the text was moved to.

    • Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection.

      Parameters

      • Optionaltimes: number

        The number of times to change navigation

      Returns void

    • Moves the cursor to the end of the current file. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor to the start of the current file. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection.

      Parameters

      • Optionaltimes: number

        The number of times to change navigation

      Returns void

    • Moves the cursor to the end of the current line. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor to the start of the current line. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection.

      Parameters

      • Optionaltimes: number

        The number of times to change navigation

      Returns void

    • Moves the cursor to the specified row and column. Note that this does de-select the current selection.

      Parameters

      • row: number

        The new row number

      • column: number

        The new column number

      Returns void

    • Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection.

      Parameters

      • Optionaltimes: number

        The number of times to change navigation

      Returns void

    • Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection.

      Returns void

    • Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection.

      Returns void

    • opens a prompt displaying message

      Parameters

      • message: any
      • options: any
      • callback: any

      Returns void

    • Removes the current selection or one character.

      Parameters

      • Optionaldir: "left" | "right"

        The direction of the deletion to occur, either "left" or "right"

      Returns void

    • Parameters

      • Optionalname: string

      Returns void

    • Parameters

      • name: string
      • callback: Function

      Returns void

    • Removes all the lines in the current selection

      Returns void

    • Removes all the words to the right of the current selection, until the end of the line.

      Returns void

    • Removes all the words to the left of the current selection, until the start of the line.

      Returns void

    • Removes the word directly to the left of the current selection.

      Returns void

    • Removes the word directly to the right of the current selection.

      Returns void

    • Replaces the first occurrence of options.needle with the value in replacement.

      Parameters

      • Optionalreplacement: string

        The text to replace with

      • Optionaloptions: Partial<SearchOptions>

        The [[Search Search]] options to use

      Returns number

    • Replaces all occurrences of options.needle with the value in replacement.

      Parameters

      • Optionalreplacement: string

        The text to replace with

      • Optionaloptions: Partial<SearchOptions>

        The [[Search Search]] options to use

      Returns number

    • {:VirtualRenderer.onResize}

      Parameters

      • Optionalforce: boolean

        If true, recomputes the size, even if the height and width haven't changed

      Returns void

    • Scrolls the document to wherever "page down" is, without changing the cursor position.

      Returns void

    • Scrolls the document to wherever "page up" is, without changing the cursor position.

      Returns void

    • Scrolls to a line. If center is true, it puts the line in middle of screen (or attempts to).

      Parameters

      • line: number

        The line to scroll to

      • center: boolean

        If true

      • animate: boolean

        If true animates scrolling

      • Optionalcallback: () => void

        Function to be called when the animation has finished

      Returns void

    • Moves the editor to the specified row.

      Parameters

      • row: number

      Returns void

    • Selects the text from the current position of the document until where a "page down" finishes.

      Returns void

    • Selects the text from the current position of the document until where a "page up" finishes.

      Returns void

    • Enables automatic scrolling of the cursor into view when editor itself is inside scrollable element

      Parameters

      • enable: boolean

        default true

      Returns void

    • Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef}

      Parameters

      • enabled: boolean

        Enables or disables behaviors

      Returns void

    • Parameters

      • name: string
      • callback: Function

      Returns void

    • Sets the delay (in milliseconds) of the mouse drag.

      Parameters

      • dragDelay: number

        A value indicating the new delay

      Returns void

    • Set a new font size (in pixels) for the editor text.

      Parameters

      • size: string | number

        A font size ( e.g. "12px")

      Returns void

    • Set the "ghost" text in provided position. "Ghost" text is a kind of preview text inside the editor which can be used to preview some code inline in the editor such as, for example, code completions.

      Parameters

      • text: string

        Text to be inserted as "ghost" text

      • Optionalposition: Ace.Point

        Position to insert text to

      Returns void

    • Determines whether or not the current line should be highlighted.

      Parameters

      • shouldHighlight: boolean

        Set to true to highlight the current line

      Returns void

    • Parameters

      • shouldHighlight: boolean

      Returns void

    • Determines if the currently selected word should be highlighted.

      Parameters

      • shouldHighlight: boolean

        Set to true to highlight the currently selected word

      Returns void

    • Parameters

      • optList: Partial<T>

      Returns void

    • Pass in true to enable overwrites in your session, or false to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of overwrite changes, this function also emits the changeOverwrite event.

      Parameters

      • overwrite: boolean

        Defines whether or not to set overwrites

      Returns void

    • Sets the column defining where the print margin should be.

      Parameters

      • showPrintMargin: number

        Specifies the new print margin

      Returns void

    • If readOnly is true, then the editor is set to read-only mode, and none of the content can change.

      Parameters

      • readOnly: boolean

        Specifies whether the editor can be modified or not

      Returns void

    • Sets how fast the mouse scrolling should do.

      Parameters

      • speed: number

        A value indicating the new speed (in milliseconds)

      Returns void

    • Draw selection markers spanning whole line, or only over selected text. Default value is "line"

      Parameters

      • val: "line" | "text" | "fullLine" | "screenLine"

        The new selection style "line"|"text"

      Returns void

    • Indicates whether the fold widgets should be shown or not.

      Parameters

      • show: boolean

        Specifies whether the fold widgets are shown

      Returns void

    • If showInvisibles is set to true, invisible characters—like spaces or new lines—are show in the editor.

      Parameters

      • showInvisibles: boolean

        Specifies whether or not to show invisible characters

      Returns void

    • If showPrintMargin is set to true, the print margin is shown in the editor.

      Parameters

      • showPrintMargin: boolean

        Specifies whether or not to show the print margin

      Returns void

    • {:VirtualRenderer.setStyle}

      Parameters

      • style: string

        A class name

      • Optionalincluude: boolean

        pass false to remove the class name

      Returns void

    • {:VirtualRenderer.setTheme}

      Parameters

      • theme: string | Ace.Theme

        The path to a theme

      • Optionalcb: () => void

        optional callback called when theme is loaded

      Returns void

    • Sets the current document to val.

      Parameters

      • val: string

        The new value to set for the document

      • OptionalcursorPos: number

        Where to set the new value. undefined or 0 is selectAll, -1 is at the document start, and 1 is at the end

      Returns string

      The current document value

    • Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets when such a character is typed in.

      Parameters

      • enabled: boolean

        Enables or disables wrapping behaviors

      Returns void

    • Given the currently selected range, this function either comments all the lines, or uncomments all of them.

      Returns void

    • Sets the value of overwrite to the opposite of whatever it currently is.

      Returns void

    • {:VirtualRenderer.unsetStyle}

      Parameters

      • style: string

      Returns void