22 Votes

Remove Spaces from the Beginning and End of the Lines of Texts

Tutorial by Stefan Trost | 2022-10-17 at 23:41

Imagine you have texts or text files with lines that sometimes start or end with one or more spaces or tabs. You would like to delete this whitespace from every line of these texts. The problem: There are a lot of texts and a lot of lines, so that you do not want to execute this task manually. Therefore, you are looking for a way to automate this process.

With the TextConverter you can remove spaces, tabs and other types of whitespace quickly and easily from the beginning and the end of all lines of a text or multiple text files at the same time. In this tutorial we show you how to do this:

  1. If you want to edit a text, just copy it into the field "Original". If you want to edit one or more files, you can simply drop the files onto the program.
  2. Next, activate the action "Lines > Trim" on the right side of the main window.
  3. Depending on whether you want to remove the whitespace from the beginning or from the end of the lines, activate below under "Remove Spaces, Tabs and other Whitespace..." either the option "...from the Beginning of Lines" or "...from the End of Lines". Of course, you can also activate both options at the same time if you want to delete the whitespace from both sides.
  4. When you edit a text, you can see the result directly after activating the options in the field "Preview". You can copy this result with the button "Clipboard" into your clipboard in order to continue with using it. If you edit one or more text files - after you have checked the preview that the result is correct - you can click on the button "Convert and Save" to process and save all files from the file list in one go.

By default, the options "From the Beginning of each Line" and "From the End of each Line" are activated. With these options, the spaces and tabs are deleted from the beginning and/or the end of every line of your text or text files.

Limit Removal to certain Lines

If you want to limit the deletion of the whitespace to certain lines of your text, you have several options. The simplest way is to only trim lines with a certain line number. Just deactivate the option(s) for all lines and write your desired line numbers into the fields "From the Beginning of these Lines:" and/or "From the end of these Lines:". Several lines can be specified here comma separated or by using ranges. So, for example "1-10", "1,3,5" or "7,10-15,25".

If you want to select the lines according to other criteria (for example, only lines that contain a specific text or lines with odd line numbers) you can work with action lists in the TextConverter.

ReplyPositiveNegative

About the Author

AvatarYou can find Software by Stefan Trost on sttmedia.com. Do you need an individual software solution according to your needs? - sttmedia.com/contact
Show Profile

 

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.