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

**URL:** https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759
**Category:** General
**Tags:** monaco
**Created:** [26 February 2023 12:45 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759 "2023-02-26T12:45:33Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Subnum12](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/subnum12/32/76797_2.png) [@Subnum12](https://discourse.nodered.org/u/Subnum12)
#### Post date: [26 February 2023 12:45 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/1 "2023-02-26T12:45:33Z")

</div>

As [this](https://discourse.nodered.org/t/change-default-indent-from-4-to-2-spaces-in-function-nodes/23523) 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,}}

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [26 February 2023 13:09 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/2 "2023-02-26T13:09:09Z")

</div>

You can configure the Monaco editor in settings.js

```auto
        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.

> <https://stackoverflow.com/questions/41107540/how-can-i-set-the-tab-width-in-a-monaco-editor-instance>

---

<div class="post-metadata">

### Author: ![Subnum12](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/subnum12/32/76797_2.png) [@Subnum12](https://discourse.nodered.org/u/Subnum12)
#### Post date: [26 February 2023 13:15 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/3 "2023-02-26T13:15:48Z")

</div>

> [@TotallyInformation](#):
>
> I don't know what the tab-stop size setting might be

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

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

```

tabSize 2

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

```

---

<div class="post-metadata">

### Author: ![kevinGodell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kevingodell/32/27040_2.png) [@kevinGodell](https://discourse.nodered.org/u/kevinGodell)
#### Post date: [26 February 2023 13:18 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/4 "2023-02-26T13:18:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [26 February 2023 13:18 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/5 "2023-02-26T13:18:01Z")

</div>

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](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.

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [26 February 2023 14:40 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/6 "2023-02-26T14:40:42Z")

</div>

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

```auto
* 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.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [26 February 2023 14:49 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/7 "2023-02-26T14:49:04Z")

</div>

Yeah, they changed it (again).

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

> <https://github.com/node-red/node-red/issues/4074>
>
> \### Current Behavior
> 
> The link in the settings.js file for monaco creation optio…ns is dead (404)
> 
> \### Expected Behavior
> 
> Link should point to https://microsoft.github.io/monaco-editor/docs.html#interfaces/editor.IGlobalEditorOptions.html
> 
> \### Steps To Reproduce
> 
> \_No response\_
> 
> \### Example flow
> 
> \_No response\_
> 
> \### Environment
> 
> \- Node-RED version: 3.0.2+

---

<div class="post-metadata">

### Author: ![Subnum12](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/subnum12/32/76797_2.png) [@Subnum12](https://discourse.nodered.org/u/Subnum12)
#### Post date: [26 February 2023 14:53 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/8 "2023-02-26T14:53:29Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [12 March 2023 14:54 UTC](https://discourse.nodered.org/t/howto-change-default-indent-from-4-to-2-spaces-in-function-nodes/75759/9 "2023-03-12T14:54:05Z")

</div>

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