Site hosted by Angelfire.com: Build your free website today!
Chapter 17: Working with Documents in Windows XP

PreviousChapterContentsGlossaryNext

Reading Text Files with Notepad

Notepad is a holdover from Windows 3.0. Back in the Windows 3.0 era, configuration information was stored in text files that regularly needed to be edited, and Notepad could edit those files. In subsequent releases of Windows, editing configuration files has become a task more often done either automatically by installation programs or manually by system administrators and hackers than by people simply trying to make their computers work the way they want.

Notepad, however, remains available in Windows XP and using it is the simplest way to edit a text file. Sure, you can use a full-fledged word processor, but doing so is often more trouble than it's worth. Use Notepad to edit any text file (also called an ASCII file)--that is, files that contain only letters, numbers, and special characters that appear on the keyboard. Notepad can't format your text with bold, italics, or anything else pretty, but we've been known to use Notepad to edit Web pages, and it's invaluable for storing little snippets of text you might need later.

Running Notepad

To run Notepad, choose Start | All Programs | Accessories | Notepad. (Or, you can choose Start | Run to display the Run dialog box, and then type notepad and press ENTER.) Notepad looks like Figure 17-1: just a window with a menu.
[figure]
Figure 17-1: Run Notepad when you need to edit a text file.

The following sections offer some information about and tips on using Notepad.

Copying, Moving, and Pasting Text

You can copy or move text to or from the Windows Clipboard using the Edit | Copy, Edit | Cut, and Edit | Paste commands.

Document Settings

To change the setup of the document when you print it, choose File | Page Setup (this command isn't available if you haven't installed a printer in Windows). Use the Page Setup dialog box (shown in Figure 17-2) to change margins, page orientation, and paper size. (In the Orientation box, Portrait prints on paper in the usual way; Landscape prints sideways on the page, with the lines of text parallel to the long edge of the paper.) If you have more than one printer, you can select the one to use. Use the Header and Footer text boxes to add headers and footers to your documents. You can type plain text, or you can use the codes in Table 17-1.

Code Meaning
&f Displays the name of the file
&p Displays the page number
&d Displays the current date
&t Displays the current time
&& Displays an ampersand
&l Left-justifies the text after this code
&c Centers the text after this code
&r Right-justifies the text after this code
Table 1: Header and Footer Codes in Notepad
[figure]
Figure 17-2: Notepad options for printing a text file

File Types

Choose File | Open to see the Open dialog box. Change the Files Of Type option to All Files if the file you want to open does not have the .txt extension.

Fonts

Notepad normally uses a fixed-pitch font to display text files. You can change the font by choosing Format | Font to display the Font dialog box and then setting the font, style, and size.

Log Files

Create a log file by typing .LOG in the top-left corner (the very beginning) of your Notepad file (be sure to use capital letters). Each time you run Notepad and open the file, Notepad enters the current time and date at the end of the file. You can then type an entry for that time and date.

Printing

Print the text file by choosing File | Print. Notepad prints the file with the filename at the top of each page and a page number at the bottom, unless you choose File | Page Setup and change the Header and Footer settings.

Saving Files

Save the text file you are editing by choosing File | Save. To save it with a name you specify, choose File | Save As to display the Save As dialog box.

Searching for Text

You can search for a string of text by choosing Edit | Find or press CTRL-F to display the Find dialog box, and then typing the string you're looking for into the Find What text box. Click the Match Case check box if you want Notepad to find only text that matches the capitalization of the text you typed. You can also specify whether to search forward or backward in the file by clicking the Up or Down radio button. Start the search by clicking the Find Next button. To search for the same string again, press F3 or choose Edit | Find Next.

If you want to replace text, choose Edit | Replace or press CTRL-H to display the Replace dialog box. Type the string you're looking for into the Find What text box, and type the string you want to use as the replacement in the Replace With text box. Click Find Next to find the first instance of the string. You can replace all occurrences by clicking Replace All, or you can pick and choose by clicking Replace (if you want to replace the text) or Find Next if you want to skip an instance. The Replace dialog box, like the Find dialog box, provides a check box to use if you want to match the case of the Find What and Replace With strings.

Moving Around Text Files

You can move quickly through a large file by using the Go To option--choose Edit | Go To or press CTRL-G to display the Go To Line dialog box. Enter the line number that you want to go to and either click OK or press ENTER. The dialog box disappears, and the cursor moves to the specified line.

If you want to know where you are in a document, you may find the status bar useful--it displays the cursor position in lines and columns (Ln 4, Col 6 is the sixth character on the fourth line in the document). Display the status bar by choosing View | Status Bar.

Time and Date

You can insert the current time and date (according to your computer's clock) at the cursor by choosing Edit | Time/Date, or by pressing F5.

Undo

If you make a mistake, you can reverse your last edit by choosing Edit | Undo or pressing CTRL-Z.

Word Wrap

As you work with a document, you might want to turn on the Word Wrap, so that Notepad breaks long lines to fit in the Notepad window. When Word Wrap is off, each paragraph appears as a single long line (unless it contains carriage returns). Turn on (or off) Word Wrap by choosing Format | Word Wrap. Notepad then wraps lines the way a word processor wraps lines, so no line is wider than the Notepad window. The Notepad Word Wrap feature doesn't add carriage return characters to the text file when you save it and it doesn't affect the way the file appears when printed.

Files You Can Edit with Notepad

The standard file extension for text files is .txt. When you click or double-click a .txt file in Windows Explorer, Windows runs Notepad to view the file.

Windows associates a number of other types of files with Notepad, too, because these files contain only text and are usually small enough for Notepad to handle. These file types include:

PreviousChapterContentsGlossaryNext