TabSize seems to be ignored (config help requested)

I’m learning CM 6 after using CM 5 previously.

I have a very basic editor config:

import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { python } from '@codemirror/lang-python';
import { basicSetup } from '@codemirror/basic-setup';

const state = EditorState.create({
  extensions: [

new EditorView({
  state: state,
  parent: DOM_ELEMENT,

The editor renders and works perfectly apart from the tabSize. If I log state.tabSize I get 4.

However, if I type some Python code that triggers an indent, such as:

while True:
  a = 2 # a dumb example

When I hit return after the while to start the second line I get an indentation of 2 spaces, I would have expected 4…

Have I missed a step or misunderstood what tabSize refers to?

I found an answer to my own question. For anyone else that gets confused:

tabSize refers to the number of columns a tab takes up. It does not effect the amount of indentation.

This differs from other editors you may be used to, the “Tab Size” setting in VS Code for example.

If you are not using tabs at all you want to change the number of spaces used to indent, you want the indentUnit facet. More detail here: CodeMirror 6 set indentation unit

1 Like