Angular-cli: Feature: Add option for setting indentation

Created on 7 Oct 2016  路  15Comments  路  Source: angular/angular-cli

I think I'm not the only one who prefers tabs to spaces. Also I know that many people use different space count on indentation.
I suggest adding defaults.indent option to angular-cli.json.

Most helpful comment

Well, that referenced issue didn't end too good.

Quite frankly I do not understand why there is a really nice .editorconfig but after setting the indent_size to 4 from 2 and executing ng g component mycomponent I still have to use the inbuilt option in visual studio code to format document to be 4 spaces long for each tab as I set it in my preferences. Just why this file is there if CLI ignores it? Does it also ignores rest of it or just this one option?

This really isn't an issue for professional programmers who know their tools but from time to time you can get that amazing opportunity to have an intern on your project who will touch the codebase and I think this option could be helpful for those guys and also you're gonna have one thing less on your list of things you have to watch that guy for.

All 15 comments

Curious, what would this be used for? I am assuming you are talking about how the code is laid out; couldn't you modify that in your IDE?

@fullstackdave yes, ofc I can, but I have to do this with every file file generated. I think I can automate it (I'm using Sublime Text 3), but I use it for other projects and I don't know how to do it without any problems with other files.

Well, that referenced issue didn't end too good.

Quite frankly I do not understand why there is a really nice .editorconfig but after setting the indent_size to 4 from 2 and executing ng g component mycomponent I still have to use the inbuilt option in visual studio code to format document to be 4 spaces long for each tab as I set it in my preferences. Just why this file is there if CLI ignores it? Does it also ignores rest of it or just this one option?

This really isn't an issue for professional programmers who know their tools but from time to time you can get that amazing opportunity to have an intern on your project who will touch the codebase and I think this option could be helpful for those guys and also you're gonna have one thing less on your list of things you have to watch that guy for.

+1 I really don't understand, I have to re-edit everytime the scaffolded files

@mpragliola the blueprint files are tab space 2. There isn't a setting to change tab space, you would need a whole new blueprint with tab space 4 or run some formatter on the newly generated file with your config settings.

Yeah, that other thread aside... I'm with everyone else who would like this feature, and it seems like if you have the value set in .editorconfig it should be honored. Having to reformat everything the cli generates is not desirable.

@prestonvanloon what about replacing the double-spaces with an arbitrary character and then using the .editorconfig to replace that character on the way out?

I would also like the feature to generate components etc. with tabs instead of spaces. Thank you.

:+1:

Agreed. I am loving the CLI but i spend half my time converting from tabs to spaces and then 2-4 width.. To have this configurable would be the polish on an otherwise super useful tool.

Since it seems that this issue will not be fixed anytime soon and since it takes some time to manually format the files every time I create a component (and I create them very often), I've made an ugly, not recomended workaround for this: I edited the file npm_modules/@angular/cli/blueprints/component/files/__path__/__name__.component.ts to have my usual formatting (with tabs).

Please note that this is a workaround and it's not recommended.

And please, please, let's not argue what is "best" or "right" about using tabs, spaces or their sizes. Let's just accept that each professional likes the configuration that is best for their eyes 馃槂

I love tabs and hate spaces, plz halp!

This should be available soon-ish via automatically running TS Lint fixers on generators. This is being tracked in #6272.

@kleber-swf Genius

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngvarKofoed picture IngvarKofoed  路  3Comments

rwillmer picture rwillmer  路  3Comments

jmurphzyo picture jmurphzyo  路  3Comments

5amfung picture 5amfung  路  3Comments

gotschmarcel picture gotschmarcel  路  3Comments