void (@NotNull Document document, int line1, int line2, @NotNull CharSequence text) { TextRange currentTextRange = getLinesRange(document, line1, line2); int offset1 = currentTextRange.getStartOffset(); int offset2 = currentTextRange.getEndOffset(); document.replaceString(offset1, offset2, text); }