Text colourization in TextEditor


I am needing to do text colourization similar to the kind find in most code editors and the only way i have found to do this with pre-existing text is to find the index of the token i want to colourize, then copy it, delete it, and insert it back with setColour being set to the new colour. is this the only way to do this? is there any way to specify this?