Preserve indentation on empty line

I have the code shown in the tab example. If I:

  1. Create a new empty line
  2. Indent that line some steps
  3. Press enter (create a new line)

Then the new line is indented as much as the previous line. This works as I want. But the indentation of the previous line is deleted, and it becomes an empty line. I don’t want that; I want the previous line to keep its indentation.

Does anyone know what I can use to get the functionality I want?


A bit off topic, but I ended up using Monaco Editor instead:

import monacoLoader from '@monaco-editor/loader';
async function showEditor(editorContainer){
	const monaco = await monacoLoader.init()
	monaco.editor.create(editorContainer, {
		trimAutoWhitespace: false, // The magic setting!
		language: 'javascript',