How can you indent multiple lines all at once?

Following the principles of white-spacing and indenting, if I needed to wrap multiple already written lines in a new tag/element, how do I add additional indentation to all those lines simultaneously?

This is very late, but for anyone who comes across this: You can indent multiple things by selecting everything you want to indent, and then press [Tab].

(this is also the reason i prefer always using [Tab] instead of [spacebar] for indenting)

60 Likes

That’s really helpful, thanks!

1 Like

Great tip. I had the problem when I copied an example to my existing text but could not indent them to fit in at once. This tip is good. Thanks.

1 Like

Oh man…
What a helpful tip!!
Thanks

1 Like

wow, exactly what I needed
thank you

Thanks for this awesome tip.

I discovered this today before we got to this question, mostly because I didn’t want to tab each row individually. By trial I selected all the rows and hit tab and Wahlah!

If you prefer using [spacebar] to indent your code rather than using [tab], you can select multiple lines by holding the [alt] key and clicking on the beginning of each line you want to indent. Then, you can press [spacebar] and all the selected lines will be affected.

4 Likes

select the lines you want to indent and press ‘tab’ for forward indent and ‘shift+tab’ for backward indent

2 Likes

omg it moves! thank you!

thanks @zormus as a newbie i found this extremely helpful!

There are also shortcuts that can be useful for formatting code in Codecademy editor:

  1. Select lines above/below cursor: Ctrl + Shift + up/down arrow
  2. Duplicate line: Shift + Alt + up/down arrow
    • You can also select a few lines and then use this shortcut to duplicate some bigger parts of your code!
  3. Multiple cursors (two shortcuts for this one):
    • Alt + click left mouse button in the place you want to set an additional cursor
    • Alt + Ctrl + up/down arrow (put a cursor above/below current one)

I hope these shortcuts will speed up your work with code :wink: