Function to reident selected /whole code #33

Closed
opened 2011-02-28 23:16:17 +01:00 by marijnh · 3 comments
marijnh commented 2011-02-28 23:16:17 +01:00 (Migrated from gitlab.com)

In CodeMirror1 there was a useful function reindent(). How to achieve the same functionality in CM2? Would be handy to have such a feature.

In CodeMirror1 there was a useful function reindent(). How to achieve the same functionality in CM2? Would be handy to have such a feature.
marijnh commented 2011-03-01 07:31:54 +01:00 (Migrated from gitlab.com)

I think this should work:

function reindentCM(instance) {
  for (var i = 0, e = instance.lineCount(); i < e; ++i) instance.indentLine(i);
}
I think this should work: ``` function reindentCM(instance) { for (var i = 0, e = instance.lineCount(); i < e; ++i) instance.indentLine(i); } ```
marijnh commented 2011-03-01 07:32:36 +01:00 (Migrated from gitlab.com)

(Or, to clarify, I don't think this warrants a separate API function, if it's so easy to do through the existing API.)

(Or, to clarify, I don't think this warrants a separate API function, if it's so easy to do through the existing API.)
marijnh commented 2011-03-01 12:24:23 +01:00 (Migrated from gitlab.com)

Thank's for clarification!
Works like a charm!

Thank's for clarification! Works like a charm!
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/codemirror5#33
No description provided.