Programmatically editing the Editor content

It appears the CodeMirror editor display does not display the entire document therefore the normal DOM operations are limited to what is displayed.

Is it possible to programmatically make changes, for example, remove trailing spaces etc?

Yes, for example through replaceRange.

Thank you. replaceRange. seems to deal mostly with text find/replace, similar to search/search.js.
In fact, since I use changing the CodeMirror.fromTextArea() method, it is easier to run RegEx on the textarea.value directly.

I was looking for DOM method. For example:

document.querySelectorAll('.cm-trailingspace').forEach(item => item.remove()):

I was looking for DOM method.

Messing with the editor DOM like that is very much not supported (and, as you found, won’t work anyway).

OK… thank you :+1: