Any way to change the indentation in the code editor?

I think 4 spaces is the number the universe intended us to use. Is there any way for me to select the indentation in the code editor? It seems to be hardcoded to 2 spaces.

4 Likes

Although I agree it should be an option, I’ve been using 2 (or tabs FTW) for the past decade and I think a lot of developers are used to the tighter format now.

2 Likes

There are a class of text editor settings and conventions that our approach is to be more opinionated on. We’re not saying these options aren’t without merit - most of us have certainly had battles or discussions about them.

We’re designing Gomix with an assumption that if people aren’t confronted with low level choices like this. Ideally, this approach will have a couple benefits to their life:

  • they’ll instead focus on issues around their actual code, or on the problem they’re trying to solve
  • we can help people avoid a deep, dark internet rabbit hole
  • no one should feel like they’re doing it wrong, or that they have to understand and make the “right” choice before coding
  • consistent conventions make browsing other people’s code easier - especially helpful in a remix or collaboration scenario
2 Likes

I certainly see your point @pketh, thank you.

Since I’m interested in using Python with gomix I’d just like to add that it’s the default for Python to use four spaces, so I’m not sure how well this opinionated stance will hold outside of Javascript and maybe Ruby. It might just be me, but since proper Python code has four spaces I would probably still use those for Python code, even if it means double-tabbing in your editor. Especially if I’m creating a mix for educational purposes.

Someone copying over my example to a proper Python codebase would have to use four spaces anyway, to not go against the grain.

Therefore, if the spacing is fixed it should probably be configured on a per-language basis. Though you basically enter the same rabbit hole again.

1 Like

Language specific defaults makes sense to me. We’re still discussing internally whether multi language support is something we’ll want to focus on right now though

Hi there, I also would like to use 4 spaces in JavaScript, as I am used to this. I think the project should have a little settings file with indentation setting, preferably per language.

I would like to throw out the suggestion to allow Glitch to support .editorconfig settings. That way every project can define how their code should appear. Default the project to 2 spaces and let authors change.

3 Likes

This also allows authors to set preferences on a per-file type basis. CSS can have a different coding style than JS or whatever.

.editorconfig support makes sense, it requires some editor plumbing updates on our end but nothing too crazy hopefully, I’ll add it to our todo list

thx

4 Likes

Heya is there any update on this todo item? I am still looking forward to this feature.

I suppose you could make it a feature request.

any updates to this?

1 Like

Hi there - no updates on this, no - but I’ll make a fresh ticket and see if we can work this into upcoming product work. I’ve also changed this topic over to Feature Requests.

Disclaimer: I have not done much research on code mirror so this might not be viable
so why not export the codemirror instance so it can be accessed by other injected scripts so users can mod the editor more easily.

Does Glitch use CodeMirror? I would think if it did then it would leverage more of its built-in syntax highlighting at the very least. With regards to editor indentation, etc., EditorConfig support is practically part of its API through its configuration capabilities.

:thinking:

Yes !

in fact if you inspect the page you will see a code miror class

inspect on the code editor to make it easier

Hi @Evan_Hartono! Welcome to the community, but please don’t reply to very old posts, that will make them go to the top of the list!