CodeMirror 6 set indentation unit

I want to set indentUnit to four spaces instead of the default two in CM 6 using just the defaultHighlightStyle with no additional syntax highlighting.

Can anyone provide an example setup for that to help a beginner?

Let me just add that I did go through the documentation and tried to wrap my head around the facet concept and how to mod a value like this. The solution escapes me, and googling didn’t bring many clues regarding CM6.

… so take this as a humble question as well as an anecdote about a beginners experience diving into CM6 (which is an amazing product in so many ways).

You need to add indentUnit.of(" ") (four space, which the forum seems to collapse) from @codemirror/language to your configuration.

2 Likes

It works, thanks, I appreciate it!

@larsp @marijn

You need to add indentUnit .of(" ") (four space, which the forum seems to collapse) from @codemirror/language to your configuration.

Does “add to my configuration” mean add another extension to my EditorStateConfig?

If so, where do I get indentUnit from? Do I import it from somewhere?

Some places I have tried to find it:

import {Indentation} from '@codemirror/language'
Indentation.indentUnit
import {LanguageDescription} from '@codemirror/language'
LanguageDescription.indentUnit

Yes.

Yes, from @codemirror/language. There’s no Indentation export, just import indentUnit directly.