void (@NotNull Document document) { ApplicationManager.getApplication().runWriteAction(() -> { int i = 1; while(i < document.getLineCount()) { final int start = document.getLineEndOffset(i); final int end = document.getLineEndOffset(i) + document.getLineSeparatorLength(i); document.deleteString(start, end); i++; } }); }