Asked
Updated
Viewed
103k times

Is there a way to replace a character in WordPad with a return character, otherwise known as a carriage return or new line? For example, the line:

I like to have a return here. And so this will become the second line.

I want to replace the characters . to also include the return character so that the second line will be on a new line like below:

I like to have a return here.
And so this will become the second line.

Again, I want the return character to work in WordPad.

  • 0
    Are you trying to write code for a web page in Wordpad I use Notepad and Wordpad frequently to write web pages. If so, in HTML, the line break is always <br> unless you are writing in xhtml in which case it is <br />. If that's not what you were after, could you be slightly more specific about what you want to do? — Mark Bowker
  • 0
    Actually, I'm not writing any webpage code. All I'm trying to do is replace some characters with a return character. I receive a file that has lines that need to be replaced with a return character so it's not wrapped in one chunk of words. I need the sentences to be in different paragraphs. — ljCharlie
  • 0
    Just position your cursor where you want the line break and hit Enter. — Mark Bowker
  • 0
    Yes, that is always a possibility but the problem is there are thousands of returns that I need to "hit" the return key and I don't want to do that. So I think there must be a hidden return key in WordPad or Notepad to make this thing easier. — ljCharlie
  • 0
    Unfortunately, both WordPad and Notepad are simple text editors. You can complain to the person who sent you the file, but I think you'll need to do it by hand with Wordpad. You might try pulling the file up in Microsoft Word or an HTML editor and do a find and replace, but in Wordpad, I never found any other way to do it other than the way I suggested. — Mark Bowker
add a comment
0

8 Answers

  • Votes
  • Oldest
  • Latest
Answered
Updated

Here is an interesting way to solve this without any other editors other than WordPad itself.

  1. Click on the Replace button at the top right of WordPad.
  2. Replace the . character with the string .<br>. Use Replace All.
  3. Save the file as a .html file using the type Text Document (*.txt)
  4. View the page in your favorite browser such as Chrome, Firefox, or Edge
  5. Copy and paste the browser's rendered result

This worked for me without any fancy editors. Dirty, gritty, perfect!

1
Answered
Updated

I used to do this kind of stuff all the time. A search and replace like the one you're describing can be done easily using any version of Corel WordPerfect.

Find: .
Replace with: .[Hrt]

[Hrt] is the WordPerfect character code for carriage returns.

  • 0
    This was an old topic. Where did you dig it up? That is very useful though! One up Corel, one down MS! — Truce
1
Answered
Updated

Posting a reply in case anyone else lands on this from a search engine the way I did.

Use EditPlus!

Copy the character you want to search, and then in the Replace box, click the little drop-down arrow on the right of it and select New Line.

It will insert the \n character, not the escaped "\n" as does with Notepad or WordPad.

Here is a screenshot of the EditPlus editor:

Edit Plus Screenshot

1
JO
184 4
Answered
Updated

Notepad2 has a regular expression search/replace allowing a replace of (.*?\.)[ ]* with \1\n creating newlines with periods intact. It's exactly like Window's Notepad with all of the little utilities you wish notepad had 😁

Before hitting the Replace All button:

Notepad2 before hitting replace all

After hitting the Replace All button you can see it properly moves the sentence to the next line:

Notepad2 after hitting replace all

  • 0
    As of November, 2021 this little text utility still works perfect with Windows 10! — Brian Wozeniak
add a comment
1
Answered
Updated

In XP's version of Wordpad, go to View, Options. You can set all the wrap settings there. I imagine it's similar in other versions.

  • 0
    Well, dang it UNFLUX, I've been playing with Wordpad all these years and dunce that I am never looked there. Crap, that would have saved me some hours trying to do the same thing ljCharlie is doing. A BIG thanks on that one. kicks self, kicks self, *kicks self. — Mark Bowker
  • 0
    hahahaha 🤣 Don't kick yourself too hard. 😛 Well, I know in Notepad it has the Word Wrap setting, so I figured Wordpad would as well. 😉 — UNFLUX
  • 0
    Yes, I turned the wrap option off. Somehow it still wasn't working right. I did replace all the characters that needed to be replaced with a <br> but still is not working. Some parts of the file are still not working right. Now here's the bigger picture of the problem I'm facing. I receive this plain text email that contains a bunch of data. I copy those data into a Word Pad and automatically, as it used to work before, give me a formated data that I can easily impor that file into MS Excel. Somehow, it's not working this time. I'm not sure if it has to do with settings in Outlook 2002 or the Word Pad that is not giving me that format I used to get. Which brings me back to the initial question, how do I replace a character with a return character? If I can figure out how this problem occurs, I don't have to replace it with a return character at all. — ljCharlie
  • 0
    Try "Rich text" tab - wrap to Window. I think based on UNFLUXES' post it may depend on the format they sent it to you in. — Mark Bowker
  • 0
    Not working either. Is there a free text program that I use to paste the data from Outlook into? I want to see if it does the same thing. Right now only have Notepad, WordPad, and MS Word 2002. However, Word 2002 doesn't support sentences that have a very long width unless I'm not aware of it. What about MS Word? Is there a way I can put a return character in MS Word? And can I display the texts without a limit on the width in MS Word? — ljCharlie
  • 0
    The only thing I can suggest is to make sure you have the wrapping ON not off. You want the setting to carriage it down. — UNFLUX
0
Answered
Updated

If you don't already have it, download HTML-kit. It's free.

Open the file in HTML-kit, then run HTML Tidy (The F9 key).

HTML tidy cleans up the wrap thing and you may be able to copy and paste it into Wordpad or Word or whatever and get to where you want to be. When you open the file it should quickly do line breaks on the text, then just copy it back into Wordpad and save it. It's a shot in the dark but it may work.

By the way, when you try to open the file, you may have to change it to "all files", but if I remember correctly it will pull up text files.

  • 0
    How do I use the HTML Tidy? I want to clean the wrap texts and see if that helps a bit. — ljCharlie
  • 0
    F9, then afterward copy output to the editor. Then copy and paste from the editor back to WordPad. — Mark Bowker
  • 0
    I got it working now. It's a little tedious but it works. — ljCharlie
0
Answered
Updated

You may want to do this in Microsoft Word. You can do a find and replace using . in the Find box and .^l (lowercase L) in the Replace box. This will insert a line break after each period.

  • 0
    ^l doesn't work in WordPad and Notepad, correct? Unfortunately, I was unable to get MS Word to not wrap the texts so that's why I use WordPad or Notepad. — ljCharlie
0
Answered
Updated

If you want to simply put a new line in where each full stop occurs, you could do this programmatically with Java. Here is the script to use:

import java.io.*;

public class ReturnScript {

	private String filename = "test.txt";	// edit this
	private String outfile = "test2.txt"; // edit this
	private String find = ".";

	public ReturnScript() {
		try {
			BufferedReader br = new BufferedReader(new FileReader(filename));
			String data = "";
			String temp;
			while((temp = br.readLine()) != null) {
				data += temp;
			}
			br.close();
			BufferedWriter bw = new BufferedWriter(new FileWriter(outfile));
			java.util.StringTokenizer st = new java.util.StringTokenizer(data, find);
			while(st.hasMoreTokens()) {
				bw.write(st.nextToken()+System.getProperty("line.separator"));
			}
			bw.flush();
			bw.close(); 
		}
		catch(Exception e) { System.err.println(e.toString()); }
	}

	public static void main(String[] args) {
		ReturnScript rs = new ReturnScript();
	}
}

You will need the Java SDK installed. Compile the above code and run it, substituting in the appropriate filenames of your input file, and the file you wish to use as output.

0