Easy Way to Add Spaces to the Beginning of Each Line of Multi-line Text/String

This page is going to show you the easiest way to take a string that spans multiple lines, and add spaces to each line.

For example, lets say you have the following lines of text:

Let’s assume you wish to add a space of 10 characters in length to the beginning of each line so it becomes …

The most common approach would be to call the split function and then join each line add the space beforehand:

While this will certainly work it is a lot more processor and YOU effort than required. Try this instead: