Change (String originalText, final String[] what, final String[] into) { assert what.length == into.length; final StringBuilder sb = new StringBuilder(originalText); for (int i = 0; i < what.length; i++) { final String whatItem = what[i]; final String intoItem = into[i]; final int idx = sb.indexOf(whatItem); assert idx >= 0; sb.replace(idx, idx + whatItem.length(), intoItem); } myNewText = sb.toString(); setFileText(myChildData, myNewText); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); final FilePath fp = VcsUtil.getFilePath(myChildData); return new Change(new SimpleContentRevision(originalText, fp, "1"), new SimpleContentRevision(myNewText, fp, "2")); }