void () { DocumentImpl document = (DocumentImpl)getEditor().getDocument(); PsiDocumentManager manager = PsiDocumentManager.getInstance(getProject()); manager.commitDocument(document); document.setStripTrailingSpacesEnabled(true); document.stripTrailingSpaces(getProject()); manager.commitAllDocuments(); }