Use `editor.document` here.
Align this assignments too, and don't declare the variables inside the loop. Add them to the preview var declaration or a new one where you just declare the variables. Something like `var from, to, line, multiline;`.