[HowTo] Change default indent from 4 to 2 spaces in function nodes

As this was closed already I could not provide the solution but did run into same question.

It is just simple but not documented.
In settings.js go to codeEditor: {options: {tabSize: 2,}}

2 Likes

You can configure the Monaco editor in settings.js

        codeEditor: {
            /** Select the text editor component used by the editor.
             *  As of Node-RED V3, this defaults to "monaco", but can be set to "ace" if desired
             */
            lib: 'monaco', // 'ace',
            options: {
                /** The follow options only apply if the editor is set to "monaco"
                 *
                 * theme - must match the file name of a theme in
                 * packages/node_modules/@node-red/editor-client/src/vendor/monaco/dist/theme
                 * e.g. "tomorrow-night", "upstream-sunburst", "github", "my-theme"
                 */
                theme: 'vs-dark', // 'vs',
                /** other overrides can be set e.g. fontSize, fontFamily, fontLigatures etc.
                 * for the full list, see https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html
                 */
                fontSize: 14,
                //fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",
                fontFamily: 'Consolas, "Courier New", monospace',
                fontLigatures: false,
                colorDecorators: true,
                dragAndDrop: true,
                linkedEditing: true,
                minimap: { enabled: false },
                mouseWheelZoom: true,
                showFoldingControls: 'always',
                useTabStops: true,
                bracketPairColorization: {enabled: true},
            },
        },

However, I don't know what the tab-stop size setting might be. However, this thread might give some clues - it appears that you have to set it for a particular language.

It's basically how much spaces use by Tab
tabSize 4 (default)

codeEditor: {
..../** Select the text editor component used by the editor.

tabSize 2

codeEditor: {
../** Select the text editor component used by the editor.

It works. just requires a hard refresh in your browser.

Not sure if you figured it out but essentially add tabSize: 2 to your options.

See: https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IStandaloneEditorConstructionOptions.html#tabSize

EDIT

Sorry, my bad, I see you were actually letting users know "how to". Thanks for that.

@Steve-Mcl
Hey Steve,
The link you provide works but the link in settings.js does not

* for the full list, see https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneEditorConstructionOptions.html

that link results in a 404 for me.

Yeah, they changed it (again).

It was raised as an issue & i think it was updated in github (need to check)

1 Like

Updated Link:
https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IGlobalEditorOptions.html#tabSize

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.