Skip to content

keep wrapped indented text indented #502

Open
@haraldschilly

Description

@haraldschilly

feature request:

I would love to see word wrap follow the current indentation level in the text editor. See
https://codemirror.net/demo/indentwrap.html
and
codemirror/codemirror5#2085

The following image illustrates with the red line what I would like to see and the following code is all that is required to implement it:

var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 
lineNumbers: true, 
lineWrapping: true, 
mode: "text/html" 
}); 
var charWidth = editor.defaultCharWidth(), basePadding = 4; 
editor.on("renderLine", function(cm, line, elt) { 
var off = CodeMirror.countColumn(line.text, null, cm.getOption("tabSize")) * charWidth; 
elt.style.textIndent = "-" + off + "px"; 
elt.style.paddingLeft = (basePadding + off) + "px"; 
}); 
editor.refresh();

Thanks for the consideration.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions