Text folding


#1

Hello,

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

Thanks, Tomas


#2

Yes. See the markText method.


#3

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


#4

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