Text Operators

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.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.mark_all()

Mark all specified text

bpy.ops.text.markers_clear()

Clear all markers

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_select(type='LINE_BEGIN')

Make selection from current cursor position to new cursor 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, to make a selection
bpy.ops.text.new()

Create a new text data block

bpy.ops.text.next_marker()

Move to next marker

bpy.ops.text.open(filepath="", filter_blender=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_folder=True, filemode=9, display_type='FILE_DEFAULTDISPLAY', 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_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_folder (boolean, (optional)) – Filter folders
  • 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 [‘FILE_DEFAULTDISPLAY’, ‘FILE_SHORTDISPLAY’, ‘FILE_LONGDISPLAY’, ‘FILE_IMGDISPLAY’], (optional)) –

    Display Type

    • FILE_DEFAULTDISPLAY Default, Automatically determine display type for files.
    • FILE_SHORTDISPLAY Short List, Display files as short list.
    • FILE_LONGDISPLAY Long List, Display files as a detailed list.
    • FILE_IMGDISPLAY Thumbnails, Display files as thumbnails.
  • 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.previous_marker()

Move to previous marker

bpy.ops.text.properties()

Toggle text properties panel

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_image=False, filter_movie=False, filter_python=True, filter_font=False, filter_sound=False, filter_text=True, filter_btx=False, filter_collada=False, filter_folder=True, filemode=9, display_type='FILE_DEFAULTDISPLAY')

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_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_folder (boolean, (optional)) – Filter folders
  • 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 [‘FILE_DEFAULTDISPLAY’, ‘FILE_SHORTDISPLAY’, ‘FILE_LONGDISPLAY’, ‘FILE_IMGDISPLAY’], (optional)) –

    Display Type

    • FILE_DEFAULTDISPLAY Default, Automatically determine display type for files.
    • FILE_SHORTDISPLAY Short List, Display files as short list.
    • FILE_LONGDISPLAY Long List, Display files as a detailed list.
    • FILE_IMGDISPLAY Thumbnails, Display files as thumbnails.
bpy.ops.text.scroll(lines=1)

Scroll text screen

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

Scroll text screen

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

Previous topic

Surface Operators

Next topic

Texture Operators