Text folding

Hello,

is it possible to fold first 15 lines (whatever is in there) in CodeMirror?

Thanks, Tomas

Yes. See the markText method.

Hello, thanks! But I have problem:

editor.markText({line: 0, ch: 0}, {line: fold_line, ch: 0}, {collapsed: true});

Folds lines, but:

editor.markText({line: 0, ch: 0}, {line: fold_line - 1, ch: 0}, {collapsed: false});

do not unfold them.

Regards, Tomas

I’ve found answer, I need to clear() marker:

folding:
fold_marker = editor.markText({line: 0, ch: 0}, {line: fold_line - 1}, {collapsed: true});

unfolding:
fold_marker.clear();

Thanks, Tomas