Configure Angular CLI to use tabs instead of spaces

Configure Angular CLI to use tabs instead of spaces

As a tab indentation enthusiast, I wanted to use an Angular project with tabs instead of 2 spaces. Unfortunately, there are several settings to change, and the schematics used by ng CLI command supports only spaces. Despite numerous requests (e.g. here and here), Google did not decide to introduce an option to set indentation for generated files. I went through the process of making Angular project tabbed and I’ll describe it here.


The process will be much more comfortable if you remember to run git add . && git commit after every step to easily verify (git diff) and undo (git checkout -- .) changes.

First, create a new project (or start with your existing project):


Reformat existing code

Next, there are two options.

My related project

Timeline Creator

Create and export timeline graphs using an online tool

One is installing and using the Prettier package for formatting code:


Verify that the indentation changed with git diff and that no content was changed with git diff -w (which ignores whitespace differences).

If you don’t mind minor reformatting, mainly in JSON arrays:

-            "assets": [
-              "src/favicon.ico",
-              "src/assets"
-            ],
-            "styles": [
-              "src/styles.scss"
-            ],
+                                               "assets": ["src/favicon.ico", "src/assets"],
+                                               "styles": ["src/styles.scss"],

then leave that version.

Another possibility is using a Linux terminal or Git Bash. Open it and launch:


That command finds all files in the current folder which end in .js, .ts, .html, .css, .scss or .json and their path does not contain any of:

  • /.git/
  • /node_modules/
  • package-lock.json

You can add more rules if necessary. It then converts the initial spaces and converts every two spaces (-t 2) to a tab.


Run the command first without the rm and echo ... > ... lines to list the files that will be changed. If the regex is invalid, you may damage your .git files, and therefore irreversibly destroy data in your repository!

This method shouldn’t introduce any artifacts, only the whitespaces should be changed. Verify it with git diff and git diff -w.

Configure the Angular project to use tabs

As many as 3 files have to be changed to start using tab indentation.

First, the .editorconfig file that determines the setting used by your editor when you edit files. This has to be checked first (so you don’t enter spaces while editing other configuration files).

Plain Text

Next, the tslint.json file determines the linting options for TypeScript.


And, finally, angular.json needs to have lintFix: true added to all schematics. Note – if you have more, list them all. Previously there was just one default, then the option disappeared but was discovered as the settings you see below.


Now, when you generate new items using CLI, e.g. ng generate component Home, it will be indented with tabs.

5 1 vote
Article Rating

Want more?


Notify of
Inline Feedbacks
View all comments
David Andersson
David Andersson
2 years ago

Has anyone got this working for Angular 9?

David Andersson
David Andersson
2 years ago
Reply to  Łukasz Nojek

Thanks for the reply. I tried step 3, to configure Angular to use tabs. I modified .editorconfig, tslint.json and angular.json. But when I generated a component it had two spaces for indentation in the file.
I noted that the “schematics” property in angular.json didn’t have any content so I copied your code.

2 years ago


1 year ago

How can I run the shell command on a Mac terminal?

Would love your thoughts, please comment.x