Select words without indentation in text editor Currently you can select a line with the select_line command. The problem is that you select the complete line, with the indentations.

I'd like to know how I can select only the words of the current line, to integrate it in a pie please.
def execute(self, context):

    bpy.ops.text.move(type='LINE_BEGIN')
    bpy.ops.text.move(type='NEXT_WORD')
    bpy.ops.text.move_select(type='LINE_END')
    return {'FINISHED'}


This selects whitespace at the end of the line.