void (final String with) { SelectionModel sel = getEditor().getSelectionModel(); getEditor().getDocument().replaceString(sel.getSelectionStart(), sel.getSelectionEnd(), with); PsiDocumentManager.getInstance(getProject()).commitAllDocuments(); }