v6 Enter key should run insertNewline

Hello codemirror team,

When I press “Enter” key, I want to run insertNewLine whereas right now it runs insertNewlineAndIndent. Is something missing in the config for this?

I am using Codemirror 6 with following extensions -

this.view = new EditorView({
			doc: this.props.value,
			extensions: [
				eventHandlers, 
				basicSetup,
				language,
				keymap.of([defaultKeymap, indentWithTab, {key: "Enter", run: insertNewline}]),
				placeholder(this.props.control.additionalText),
				this.handleUpdate(),
			],
			parent: this.editorRef.current
		});

Put your keymap above the basic setup in your configuration, so that it has a higher precedence.

2 Likes

Thanks, it worked :slight_smile: