Text Operators

bpy.ops.text.autocomplete()

Show a list of used text in the open document

bpy.ops.text.comment()

Convert selected text to comment

bpy.ops.text.convert_whitespace(type='SPACES')

Convert whitespaces by type

Parameters:type (enum in ['SPACES', 'TABS'], (optional)) – Type, Type of whitespace to convert to
bpy.ops.text.copy()

Copy selected text to clipboard

bpy.ops.text.cursor_set(x=0, y=0)

Set cursor position

Parameters:
  • x (int in [-inf, inf], (optional)) – X
  • y (int in [-inf, inf], (optional)) – Y
bpy.ops.text.cut()

Cut selected text to clipboard

bpy.ops.text.delete(type='NEXT_CHARACTER')

Delete text by cursor position

Parameters:type (enum in ['NEXT_CHARACTER', 'PREVIOUS_CHARACTER', 'NEXT_WORD', 'PREVIOUS_WORD'], (optional)) – Type, Which part of the text to delete
bpy.ops.text.duplicate_line()

Duplicate the current line

bpy.ops.text.find()

Find specified text

bpy.ops.text.find_set_selected()

Find specified text and set as selected

bpy.ops.text.indent()

Indent selected text

bpy.ops.text.insert(text="")

Insert text at cursor position

Parameters:text (string, (optional, never None)) – Text, Text to insert at the cursor position
bpy.ops.text.jump(line=1)

Jump cursor to line

Parameters:line (int in [1, inf], (optional)) – Line, Line number to jump to
bpy.ops.text.line_break()

Insert line break at cursor position

bpy.ops.text.line_number()

The current line number

bpy.ops.text.make_internal()

Make active text file internal

bpy.ops.text.move(type='LINE_BEGIN')

Move cursor to position type

Parameters:type (enum in ['LINE_BEGIN', 'LINE_END', 'FILE_TOP', 'FILE_BOTTOM', 'PREVIOUS_CHARACTER', 'NEXT_CHARACTER', 'PREVIOUS_WORD', 'NEXT_WORD', 'PREVIOUS_LINE', 'NEXT_LINE', 'PREVIOUS_PAGE', 'NEXT_PAGE'], (optional)) – Type, Where to move cursor to
bpy.ops.text.move_lines(direction='DOWN')

Move the currently selected line(s) up/down

Parameters:direction (enum in ['UP', 'DOWN'], (optional)) – Direction
bpy.ops.text.move_select(type='LINE_BEGIN')

Move the cursor while selecting

Parameters:type (enum in ['LINE_BEGIN', 'LINE_END', 'FILE_TOP', 'FILE_BOTTOM', 'PREVIOUS_CHARACTER', 'NEXT_CHARACTER', 'PREVIOUS_WORD', 'NEXT_WORD', 'PREVIOUS_LINE', 'NEXT_LINE', 'PREVIOUS_PAGE', 'NEXT_PAGE'], (optional)) – Type, Where to move cursor to, to make a selection
bpy.ops.text.new()

Create a new text data-block

bpy.ops.text.open(filepath="", filter_blender=False, filter_backup=False, filter_image=False, filter_movie=False, filter_python=True, filter_font=False, filter_sound=False, filter_text=True, filter_btx=False, filter_collada=False, filter_alembic=False, filter_folder=True, filter_blenlib=False, filemode=9, display_type='DEFAULT', sort_method='FILE_SORT_ALPHA', internal=False)

Open a new text data-block

Parameters:
  • filepath (string, (optional, never None)) – File Path, Path to file
  • filter_blender (boolean, (optional)) – Filter .blend files
  • filter_backup (boolean, (optional)) – Filter .blend files
  • filter_image (boolean, (optional)) – Filter image files
  • filter_movie (boolean, (optional)) – Filter movie files
  • filter_python (boolean, (optional)) – Filter python files
  • filter_font (boolean, (optional)) – Filter font files
  • filter_sound (boolean, (optional)) – Filter sound files
  • filter_text (boolean, (optional)) – Filter text files
  • filter_btx (boolean, (optional)) – Filter btx files
  • filter_collada (boolean, (optional)) – Filter COLLADA files
  • filter_alembic (boolean, (optional)) – Filter Alembic files
  • filter_folder (boolean, (optional)) – Filter folders
  • filter_blenlib (boolean, (optional)) – Filter Blender IDs
  • filemode (int in [1, 9], (optional)) – File Browser Mode, The setting for the file browser mode to load a .blend file, a library or a special file
  • display_type (enum in ['DEFAULT', 'LIST_SHORT', 'LIST_LONG', 'THUMBNAIL'], (optional)) –

    Display Type

    • DEFAULT Default, Automatically determine display type for files.
    • LIST_SHORT Short List, Display files as short list.
    • LIST_LONG Long List, Display files as a detailed list.
    • THUMBNAIL Thumbnails, Display files as thumbnails.
  • sort_method (enum in ['FILE_SORT_ALPHA', 'FILE_SORT_EXTENSION', 'FILE_SORT_TIME', 'FILE_SORT_SIZE'], (optional)) –

    File sorting mode

    • FILE_SORT_ALPHA Sort alphabetically, Sort the file list alphabetically.
    • FILE_SORT_EXTENSION Sort by extension, Sort the file list by extension/type.
    • FILE_SORT_TIME Sort by time, Sort files by modification time.
    • FILE_SORT_SIZE Sort by size, Sort files by size.
  • internal (boolean, (optional)) – Make internal, Make text file internal after loading
bpy.ops.text.overwrite_toggle()

Toggle overwrite while typing

bpy.ops.text.paste(selection=False)

Paste text from clipboard

Parameters:selection (boolean, (optional)) – Selection, Paste text selected elsewhere rather than copied (X11 only)
bpy.ops.text.refresh_pyconstraints()

Refresh all pyconstraints

bpy.ops.text.reload()

Reload active text data-block from its file

bpy.ops.text.replace()

Replace text with the specified text

bpy.ops.text.replace_set_selected()

Replace text with specified text and set as selected

bpy.ops.text.resolve_conflict(resolution='IGNORE')

When external text is out of sync, resolve the conflict

Parameters:resolution (enum in ['IGNORE', 'RELOAD', 'SAVE', 'MAKE_INTERNAL'], (optional)) – Resolution, How to solve conflict due to differences in internal and external text
bpy.ops.text.run_script()

Run active script

bpy.ops.text.save()

Save active text data-block

bpy.ops.text.save_as(filepath="", check_existing=True, filter_blender=False, filter_backup=False, filter_image=False, filter_movie=False, filter_python=True, filter_font=False, filter_sound=False, filter_text=True, filter_btx=False, filter_collada=False, filter_alembic=False, filter_folder=True, filter_blenlib=False, filemode=9, display_type='DEFAULT', sort_method='FILE_SORT_ALPHA')

Save active text file with options

Parameters:
  • filepath (string, (optional, never None)) – File Path, Path to file
  • check_existing (boolean, (optional)) – Check Existing, Check and warn on overwriting existing files
  • filter_blender (boolean, (optional)) – Filter .blend files
  • filter_backup (boolean, (optional)) – Filter .blend files
  • filter_image (boolean, (optional)) – Filter image files
  • filter_movie (boolean, (optional)) – Filter movie files
  • filter_python (boolean, (optional)) – Filter python files
  • filter_font (boolean, (optional)) – Filter font files
  • filter_sound (boolean, (optional)) – Filter sound files
  • filter_text (boolean, (optional)) – Filter text files
  • filter_btx (boolean, (optional)) – Filter btx files
  • filter_collada (boolean, (optional)) – Filter COLLADA files
  • filter_alembic (boolean, (optional)) – Filter Alembic files
  • filter_folder (boolean, (optional)) – Filter folders
  • filter_blenlib (boolean, (optional)) – Filter Blender IDs
  • filemode (int in [1, 9], (optional)) – File Browser Mode, The setting for the file browser mode to load a .blend file, a library or a special file
  • display_type (enum in ['DEFAULT', 'LIST_SHORT', 'LIST_LONG', 'THUMBNAIL'], (optional)) –

    Display Type

    • DEFAULT Default, Automatically determine display type for files.
    • LIST_SHORT Short List, Display files as short list.
    • LIST_LONG Long List, Display files as a detailed list.
    • THUMBNAIL Thumbnails, Display files as thumbnails.
  • sort_method (enum in ['FILE_SORT_ALPHA', 'FILE_SORT_EXTENSION', 'FILE_SORT_TIME', 'FILE_SORT_SIZE'], (optional)) –

    File sorting mode

    • FILE_SORT_ALPHA Sort alphabetically, Sort the file list alphabetically.
    • FILE_SORT_EXTENSION Sort by extension, Sort the file list by extension/type.
    • FILE_SORT_TIME Sort by time, Sort files by modification time.
    • FILE_SORT_SIZE Sort by size, Sort files by size.
bpy.ops.text.scroll(lines=1)

Undocumented contribute <https://developer.blender.org/T51061>

Parameters:lines (int in [-inf, inf], (optional)) – Lines, Number of lines to scroll
bpy.ops.text.scroll_bar(lines=1)

Undocumented contribute <https://developer.blender.org/T51061>

Parameters:lines (int in [-inf, inf], (optional)) – Lines, Number of lines to scroll
bpy.ops.text.select_all()

Select all text

bpy.ops.text.select_line()

Select text by line

bpy.ops.text.select_word()

Select word under cursor

bpy.ops.text.selection_set(select=False)

Set cursor selection

Parameters:select (boolean, (optional)) – Select, Set selection end rather than cursor
bpy.ops.text.start_find()

Start searching text

bpy.ops.text.to_3d_object(split_lines=False)

Create 3D text object from active text data-block

Parameters:split_lines (boolean, (optional)) – Split Lines, Create one object per line in the text
bpy.ops.text.uncomment()

Convert selected comment to text

bpy.ops.text.unindent()

Unindent selected text

Unlink active text data-block