Fix cursor movement to the beginning and end of words