replaceChars: TextDocument implementation.