void (final @NotNull Document document, final int startLine, final int endLine, final @NotNull CharSequence indentString) { Runnable indentTask = () -> { for (int line = startLine; line <= endLine; line++) { int lineStartOffset = document.getLineStartOffset(line); document.insertString(lineStartOffset, indentString); } }; DocumentUtil.executeInBulk(document, endLine - startLine > LINE_LIMIT_FOR_BULK_CHANGE, indentTask); }