Get the App
SLTechnology News&Howtos  ›  Network Security  › 

There are many blank lines in the document, how to remove them in batches?

Shulou Source: shulou.com Published: 2022-06-01 05:24:03 09月28日 Update

As a clerk, it is inevitable to often find some text materials from the Internet. When sorting out these materials, in addition to choosing the appropriate copy and paste techniques (portal: copy and paste knowledge), many people may also encounter such problems:

Copying text from a Web page into a Word document produces N empty lines and even a lot of white space. Today, we will share the skills of dealing with such problems.

Question 1: Blank areas such as spaces

The blank area mentioned here is different from blank line, generally refers to the local blank caused by the existence of symbols such as half-angle spaces.

To remove the blank area, press Ctrl+H. In the Find and Replace dialog box, navigate to the Find Content text box, and then click the Blank Area item in Special Format, or enter ^w directly, and then click Replace All.

If you want to replace only all spaces or a special symbol, paste it into the Find What text box and replace it.

Question 2: How to replace all blank lines?

To deal with this problem, we must first find out what is OK? What is a paragraph?

When entering text in Word, when the input text exceeds the width of one line, Word will automatically switch to the next line. If you need to start a new paragraph, you need to press the Enter key manually. A paragraph can have many lines, but a paragraph must end with the [Enter] key. In a paragraph, in addition to automatic line wrapping, if you need to manually wrap, you can use the Shift+Enter key to manually wrap. The result of these two symbols in Word is as follows:

Well, once you know what a line break is and what a paragraph mark is, you can figure out what a blank line really is--just show all the edit marks.

For example, we can see that there are no newline marks at the beginning of the text, so just look for and replace blank paragraphs in the document.

In the Find and Replace dialog box, navigate to the Find Content text box, and then click Paragraph Mark in Special Format, or directly enter ^p to find all paragraph marks:

However, if you directly replace all the paragraphs, you will replace all the paragraph marks, and only one paragraph will be retained in the end, which will become the following figure:

Therefore, determining which paragraph marks are blank paragraphs is the key to dealing with the problem.

We can understand it this way: if there is a blank paragraph after a paragraph containing text, then the paragraph mark of this blank paragraph will be closely connected with the paragraph mark before the text, that is, this is how:

So, as long as there are two adjacent paragraph markers, you can be sure that one of them must be a blank paragraph! Therefore, a blank paragraph can be deleted by replacing 2 consecutive paragraph marks with 1 paragraph mark.

Enter two ^p in Find Content to find two consecutive paragraph marks; enter one ^p in Replace With text box to replace the found content with one paragraph mark. If you click the [Replace All] command several times, you will be prompted to replace it with 0, and all blank lines will be replaced.

Extension: How to remove these blank lines in batches at once?

Or the case above, if you do not want to click the [Replace All] command many times, can you replace all at once?

The answer is yes. As long as you set it as shown below, click Replace All once.

Well, share it here today. Just talk, not practice, let's try it!

Tags: Paragraphs tags blanks blank lines text questions content regions text two processing affirmation input special spaces symbols documents one line the following figure commands Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Shulou Information Docker MySQL NVidia