Select words without indentation in text editor
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.