void (@NotNull EditorEx editor) { FoldingModelEx model = editor.getFoldingModel(); CharSequence text = editor.getDocument().getCharsSequence(); model.runBatchFoldingOperation(() -> { model.clearFoldRegions(); for (int i = 0; i < text.length(); i++) { if (text.charAt(i) == '\n') { model.createFoldRegion(i, i + 1, " \u23ce ", null, true); } } }); }