How to indent several lines at once


Hi! I am wondering if there is any way to indent multiple lines of code at once—for example, when adding a div element around several lines of code that have already been written (the previous code becoming the content of this new element). It is a pain to add spaces one line at a time.


Having a text editor nearby is a must. File > New.

Paste in the lines of code you wish to add indentation to. They should all have the same indentation level or greater. Every line must have at least one level of indentation.

Run a quick scan for mixed tabs and spaces, change them all to spaces.

Find:  (type a single press of the tab key)
Replace with: '  ' (two space characters)

Now examine the code and find the lines with the most indentation. Copy the indentation spaces only.

Find: (the indentation should be here)
Replace with: (an equal number of % characters, plus 2)



'        ', with,

That’s four levels of indentation, as an example. Working up from the deepest to the top of nesting repeat the replacement procedure. Once that’s done,

Find: %
Replace with: [SPACE]


This is a CodeMirror. Here documentation.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.