Moving Around in a Text File

Most of the cursor-control keys position the cursor and modify the display just as you would expect them to. The HOME, END, PGUP, PGDN, and ARROW keys behave as they do in most other text editors.

If you click in the shaded area on either side of the scroll box in the scroll bar, you move the cursor one full window at a time. If you click the scroll-bar arrows, you move the cursor one row or column in the corresponding direction. If you click and drag the scroll box, you move the cursor to the corresponding relative position within the file.

Defining a Block of Text

One of the most common editing tasks is defining a block of text, usually before deleting, moving, or copying it.

·Keyboard

To define a block of text:

1.Move the cursor to the beginning of the block.

2.Hold down the SHIFT key and use any cursor-movement key (ARROW, HOME, PGDN, and so on) to move to the end of the block.

·Mouse

To define a block of text:

1.Click the first character at the beginning of the block. Continue pressing the left mouse button.

2.Drag the mouse to select the rest of the desired text. The block remains selected until you press a cursor movement key or click the mouse again.

NOTE:

As long as a block is defined, anything you type deletes the defined block and inserts the typed characters.

As you move the cursor or mouse to define a block, you usually select all characters from the starting cursor position to the ending cursor position. This is called “stream mode” and is the default. The Edit menu offers three text-selection modes:

Stream mode selects all text from the starting cursor position to the ending cursor position (the default).

Box mode selects text from a rectangle whose opposite corners are the starting and ending cursor positions.

Line mode selects full lines of text from the line with the starting cursor position to the line with the ending cursor position.

You can select a different mode from the Edit menu. The mode displayed in the menu is the next available text-selection mode (not the current mode). You can also move through the selection modes during text selection by clicking the right mouse button while you hold down the left mouse button.

Once a block is defined, press DEL to erase it. You can also place the block in the clipboard buffer for later use. Press CTRL+INS to copy the block to the clipboard. Press SHIFT+DEL to copy the block to the clipboard and erase it from the screen. Press SHIFT+INS to insert the current contents of the clipboard at the cursor.

Setting Bookmarks

A “bookmark” is a permanent marker that lets you quickly return to a specific section of text. A bookmark stays with the text it marks, even if the text is moved.

To set a bookmark, first position the cursor at the location you want to mark. Then select the Define Mark command from the Search menu.

In the dialog box that appears, type the name you want to give the bookmark. (The source filename and the row and column are already entered.) Press ENTER to save the bookmark for the current session. To save a bookmark for later editing sessions, use the Add To Mark File option. The Set Mark File command from the Search menu reloads previously saved bookmarks.

To move the cursor to a bookmark, choose the Go To Mark command from the Search menu. A list of all bookmarks is displayed. Select the bookmark from the list using the ARROW keys, or click the selected bookmark with the left mouse button. Press ENTER to go to the bookmark.

Setting Anchors

An “anchor” temporarily marks the beginning of selected text. It is most often used to define a block that extends beyond the current screen.

To set an anchor, move the cursor to the desired location and choose the Set Anchor command from the Edit menu. Use the Select To Anchor command from the Edit menu to select all text between the current cursor position and the anchor. Only one anchor can be set at a time.

Searching for and Changing Text

You can search for a string of text using the Find command in the Search menu. Type the string you want to look for, then use the check boxes to set options such as wrap-around search and case sensitivity. The Files button allows you to specify a list of files to search through for the designated string.

Once a string has been located, use the Repeat Last Find command in the Search menu (or press the shortcut key, F3) to move to the next occurrence of the string. If you specified several files to search, press SHIFT+F3 to move to the next file that contains that string.

To modify several instances of a string in the source file, use the Change command in the Search menu. Enter the target string, the replacement string, and the search options.

PWB also supports searching for and replacing text patterns using regular-expressions. You can use either the UNIX or Microsoft regular-expression syntax. For further information, see the online reference system.

PWB can also search for selected text in files not currently loaded. Select the Files command in the Find dialog box. From the File List box, select the name of a file that you want to search. Then click the Add/Delete button to place it in the File(s) Selected box. Repeat this step for all the files you want to search.

You can also enter a wildcard pattern in the File Name text box, and then use the Add Pattern button to place it in the File(s) Selected box. Press ENTER or click the OK button to begin the search. Use the Next Error and Previous Error commands to scan any text that is found.

Creating Macros

You can save blocks of text or frequently performed editing tasks as macros. Each macro is assigned a key combination that “plays back” the text or task.

For example, if several programmers are working on a file and need to keep track of who made what changes, a macro can be used to insert a comment with the programmer's name.

To create such a macro, use the Set Record command from the Edit menu to enter a macro name and its associated key combination. For this example, call the macro modname and assign it to the key combination CTRL+J.

Now choose the Record On command from the Edit menu. A bullet appears to the left of the menu command and an X appears in the status line, indicating that all keystrokes and menu commands are being recorded. Then type the following:

; j. courtney coded this

To stop the recording, choose Record On again, which causes the bullet to disappear. This action associates all recorded actions with the previously selected macro name. Now, each time you press CTRL+J, the comment you typed is inserted at the cursor position.

Macros are saved in the TOOLS.INI file when you save the <record> pseudofile. You can change or delete them by modifying the file. See the section “Customizing PWB” in the online reference system for additional information about macros.