user: How do I use SpaceTextEditor(Space) in Blender? Include parameters, examples, warnings and best practices.

assistant: # SpaceTextEditor(Space)

base classes — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct"), [`Space`](bpy.types.Space.html#bpy.types.Space "bpy.types.Space")

*class* bpy.types.SpaceTextEditor(*Space*)
:   Text editor space data

    find_text
    :   Text to search for with the find tool

        Type:
        :   string, default “”, (never None)

    font_size
    :   Font size to use for displaying the text

        Type:
        :   int in [1, 256], default 0

    margin_column
    :   Column number to show right margin at

        Type:
        :   int in [0, 1024], default 0

    replace_text
    :   Text to replace selected text with using the replace tool

        Type:
        :   string, default “”, (never None)

    show_line_highlight
    :   Highlight the current line

        Type:
        :   boolean, default False

    show_line_numbers
    :   Show line numbers next to the text

        Type:
        :   boolean, default False

    show_margin
    :   Show right margin

        Type:
        :   boolean, default False

    show_region_footer
    :   Type:
        :   boolean, default False

    show_region_ui
    :   Type:
        :   boolean, default False

    show_syntax_highlight
    :   Syntax highlight for scripting

        Type:
        :   boolean, default False

    show_word_wrap
    :   Wrap words if there is not enough horizontal space

        Type:
        :   boolean, default False

    tab_width
    :   Number of spaces to display tabs with

        Type:
        :   int in [2, 8], default 0

    text
    :   Text displayed and edited in this space

        Type:
        :   [`Text`](bpy.types.Text.html#bpy.types.Text "bpy.types.Text")

    top
    :   Top line visible

        Type:
        :   int in [0, inf], default 0

    use_find_all
    :   Search in all text data-blocks, instead of only the active one

        Type:
        :   boolean, default False

    use_find_wrap
    :   Search again from the start of the file when reaching the end

        Type:
        :   boolean, default False

    use_live_edit
    :   Run Python while editing

        Type:
        :   boolean, default False

    use_match_case
    :   Search string is sensitive to uppercase and lowercase letters

        Type:
        :   boolean, default False

    use_overwrite
    :   Overwrite characters when typing rather than inserting them

        Type:
        :   boolean, default False

    visible_lines
    :   Amount of lines that can be visible in current editor

        Type:
        :   int in [-inf, inf], default 0, (readonly)

    is_syntax_highlight_supported()
    :   Returns True if the editor supports syntax highlighting for the current text data-block

        Return type:
        :   boolean

    region_location_from_cursor(*line*, *column*)
    :   Retrieve the region position from the given line and character position

        Parameters:
        :   - **line** (*int in* *[**-inf**,* *inf**]*) – Line, Line index
            - **column** (*int in* *[**-inf**,* *inf**]*) – Column, Column index

        Returns:
        :   Region coordinates

        Return type:
        :   int array of 2 items in [-1, inf]

    *classmethod* bl_rna_get_subclass(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The RNA type or default when not found.

        Return type:
        :   [`bpy.types.Struct`](bpy.types.Struct.html#bpy.types.Struct "bpy.types.Struct") subclass

    *classmethod* bl_rna_get_subclass_py(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The class or default when not found.

        Return type:
        :   type

    *classmethod* draw_handler_add(*callback*, *args*, *region_type*, *draw_type*)
    :   Add a new draw handler to this space type.
        It will be called every time the specified region in the space type will be drawn.
        Note: All arguments are positional only for now.

        Parameters:
        :   - **callback** (*Callable**[**...**,* *Any**]*) – A function that will be called when the region is drawn.
              It gets the specified arguments as input, it’s return value is ignored.
            - **args** (*tuple**[**Any**,* *...**]*) – Arguments that will be passed to the callback.
            - **region_type** (*str*) – The region type the callback draws in; usually `WINDOW`. ([`bpy.types.Region.type`](bpy.types.Region.html#bpy.types.Region.type "bpy.types.Region.type"))
            - **draw_type** (*str*) – Usually `POST_PIXEL` for 2D drawing and `POST_VIEW` for 3D drawing. In some cases `PRE_VIEW` can be used. `BACKDROP` can be used for backdrops in the node editor.

        Returns:
        :   Handler that can be removed later on.

        Return type:
        :   object

    *classmethod* draw_handler_remove(*handler*, *region_type*)
    :   Remove a draw handler that was added previously.

        Parameters:
        :   - **handler** (*object*) – The draw handler that should be removed.
            - **region_type** (*str*) – Region type the callback was added to.