Enable and disable specific lines

How can i disable first few number of lines in editor, and also how can i update codemirror in this state.

I tried this to disable few lines

 var readOnlyLines = [0,1,2];
                      editor.on('beforeChange',function(cm,change) {

                         if ( ~readOnlyLines.indexOf(change.from.line) ) {



After executing above code, results in disabling of lines “1”, “2”, “3”.

But now when i try to update codemirror using

editor.setValue(<MY STRING DATA HERE>);

Then it is not updating the data.

How can i make it update after disabling few lines also.

You could check change.origin in the beforeChange hangler—it’ll be "setValue" for the setValue call.