Change Indent Size in Codecademy Editor

Hey there,

Is there a way to change the default size of the indent when you press tab? This is pretty annoying for me because when I download a project from Codecademy, it always has an indent size of 2, and I want to be able to change that to 4.

What do you use to run the project?

I don’t think there’s a way to set it in the cc editor environment at present. Even if you did you often get half complete examples which use the two space indent that you’d have to replace each time (I found it more hassle than it was worth to try). Copying code you’ve written to your own PC should be easily changed though.

A simple search/replace of the text might do. If you use a double whitespace elsewhere in the text e.g. with comments then perhaps a simple regex like the following may suit-

search=^\( *\),  replace=\1\1
^ is start of line,
\(\) is a capture group
_* is any number of space chars (the underscore should be single space char)
\1\1  replaces the captured group twice

That may still break for more complex indentation (e.g. funny multi-line options).

For a more robust option certain code editors can just do this for you or you can get python code formatter packages like autopep8, black or yapf which could do the same on a text file (dependent on settings they may alter other things too though that may suit you). Personally I’d prefer to use an auto-formatter then continue in a code editor.

1 Like

What do you mean? My code editor is VSCode