Wednesday, December 10, 2008

Editing Source Files

Editing Source Files

Figure 3-2 shows TextPad editing a Java source file. If you've worked with a Windows text editor before, you'll have no trouble learning the basics of using TextPad. I won't go over such basic procedures as opening and saving files because they're standard. Instead, the following paragraphs describe some of TextPad's features that are useful for editing Java program files.

Image from book
Figure 3-2: Editing a Java file in TextPad.

Tip

When you first create a file (by clicking the New button on the toolbar or by choosing File Image from book New), TextPad treats the file as a normal text file, not as a Java program file. After you save the file (click the Save button or choose File Image from book Save) and assign java as the file extension, TextPad's Java-editing features kick in.

The following paragraphs describe some of TextPad's more noteworthy features for working with Java files:

  • You can't really tell from Figure 3-2, but TextPad uses different colors to indicate the function of each word or symbol in the program. Brackets are red so you spot them quickly and make sure they're paired correctly. Keywords are blue. Comments and string literals are green. Other text, such as variable or method names, show as black.

  • TextPad automatically indents whenever you type an opening bracket, and then reverts to the previous indent when you type a closing bracket. Keeping your code lined up is easy.

  • Line numbers display down the left edge of the editing window. You can turn these line numbers on or off by choosing View Image from book Line Numbers.

  • To go to a particular line, press Ctrl+G to bring up the Go To dialog box. Make sure Line is selected in the Go to What box, enter the line number in the text box, and click OK.

  • If you have more than one file open, you can switch between the files by using the Document Selector, the pane on the left side of the TextPad window. If the Document Selector isn't visible, choose View Image from book Document Selector to summon it.

  • Another way to switch between two (or more) files is to choose View Image from book Document Tabs. The tabs at the bottom of the document window display. You can click these tabs to switch documents.

  • A handy Match Bracket feature lets you pair up brackets, braces, and parentheses. To use this feature, move the insertion point to a bracket. Then press Ctrl+M. TextPad finds the matching bracket.

  • To search for text, press F5. In the Find dialog box, enter the text you're looking for and click OK. To repeat the search, press Ctrl+F.

  • To replace text, press F8.

No comments:

Post a Comment