void () { doTest("<div> \n \n</div><caret>", "\n", "<div> \n \n</div>\n"); final PsiFile file = myFixture.getFile(); myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getDocument(file).getTextLength() - 2); final EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance(); String stripTrailingSpaces = editorSettings.getStripTrailingSpaces(); editorSettings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE); try { FileDocumentManager.getInstance().saveDocument(myFixture.getDocument(file)); } finally { editorSettings.setStripTrailingSpaces(stripTrailingSpaces); } myFixture.checkResult("<div>\n\n</div>\n"); }