# Using Text Editor

This chapter describes how to create and edit short documents such as memos, mail messages, or resource files using Text Editor.

UG.TextE.mkr.2
UG.TextE.mkr.3
UG.TextE.mkr.5
UG.TextE.mkr.8
UG.TextE.mkr.6
UG.TextE.mkr.9
UG.TextE.mkr.17
UG.TextE.mkr.18

## Opening and Closing Text Editor

There are several ways to start Text Editor from your desktop.

### To Open Text Editor

- Click the Text Editor control in the Front Panel.

- Or, open the Personal Applications subpanel in the Front Panel and click the Text Editor control.

Text Editor can also be started from the command line by typing this command in a Terminal window:

    dtpad filename &

The file name is optional.

### To Close Text Editor

1. Choose Close from the File menu or press Alt+F4.

If your keyboard does not have an Alt key, ask your system administrator to identify the corresponding key.

## Text Editor Window

You create and edit a document in the Text Editor window. The title bar displays the name of the current document. A new document is named (UNTITLED).

### Text Editor window

You can optionally display a status line that reports the number of lines in your document and enables you to go to a specific line number.

### To Display the Status Line

The status line displays the line number where the insertion cursor is located and the total number of lines in the document. It also reports Text Editor messages and indicates whether Overstrike mode is active.

1. Choose Status Line from the Options menu. To remove the status line, choose Status Line again from the menu.

## Opening and Saving Documents

You can create a new document or open an existing document. Opening a document displays the contents of a selected file in the Text Editor window.

Saving a document stores the edited contents into a file. You can save a document to its original file or to a new file.

### To Create a New Document

A new document named `(UNTITLED)` `is create` d when you start Text Editor.
To enter text in your document, see UG.TextE.mkr.6. You provide a new file name when you save the document.

After finishing a document, you can create another document using the New command.

1. Choose New from the File menu.

   The Text Editor window is cleared and a new document is created. If you have not saved your current document, a dialog box is displayed that enables you to save your document.

### To Save a Document to a New File

1. Choose Save As from the File menu.

   The Save As dialog box lists files and folders located in your current folder. You can store your document in the current folder, a subfolder, or a folder that you specify.

   If you used Wrap To Fit, the dialog box includes an additional choice about handling line endings. If Wrap To Fit is not set, the dialog box omits this choice (see UG.TextE.mkr.7).

   #### Save As dialog box

2. Optional. If you do not want to save the file to the current folder, choose a subfolder or indicate a different folder.

   - For a subfolder, select the subfolder in the Folders list and press Return.

   - For a different folder, use the .. (go up) icon to change to a folder or type its path name in the Enter path or folder name field.

3. Type a new file name in the Enter file name field.

4. Press Return or click OK.

### To Save a Document to the Original File

1. Choose Save from the File menu to save your work and continue editing your document.

   If you used Wrap To Fit, the Save dialog box includes an additional choice about handling line endings (see UG.TextE.mkr.7).

### Opening an Existing Document

You can open an existing document in these ways:

- Open the document in Text Editor.

- Select the file icon in File Manager and choose Open from the File Manager Selected menu.

- Double-click the file icon in File Manager.

- Drag the document's file icon to the Text Editor control in the Front Panel.

#### To Open an Existing Document from Text Editor

1. Choose Open from the File menu.

   The Open a File dialog box lists files and folders in your current folder. You can browse the documents listed, or change to a new folder to locate other files on your system.

   ##### Open a File dialog box

2. Select the name of the document you want to open, or type the document name in the Enter file name field.

3. Press Return or click OK.

You can also use this shortcut: double-click the document name in the dialog box.

#### To Open an Existing Document from File Manager

1. Display the document's file icon in a File Manager window.

   ##### Document file icon

2. Open the document in one of the following ways:

   - Double-click the document.

   - Select the document, then choose Open from the File Manager Selected menu.

   - Drag the document file icon to the Front Panel and drop the icon on the Text Editor control.

## Entering Text

As you create a document, you type and edit text. A cursor ( `I`) shows your current position. Characters are inserted unless you set Overstrike mode (see UG.TextE.mkr.10).

### To Enter New Text

1. Click in the document and start typing.

   To start a new line, press Return. Or, you can use the Wrap To Fit option to automatically wrap text at the edge of the window.

   To start a paragraph, press Return twice.

### Using Wrap To Fit

Wrap To Fit controls whether lines are automatically wrapped to fit the width of the window. When Wrap To Fit is set on, lines are broken automatically at the edge of the window. Because these line breaks are dynamic, you can resize the Text Editor window and the
text automatically adjusts to fit the new window width.

When you save your document, you decide whether to add a line break to each of the wrapped lines, or to retain the dynamic line endings. When you save your document, you choose one of these options:

- Add a newline character (hard return) to the end of each wrapped line to preserve each line ending as it currently appears.

- Or, preserve only line breaks that were created by pressing Return.

#### To Set Wrap To Fit On or Off

1. To set Wrap To Fit on, choose the Wrap To Fit toggle button in the Options menu. To set Wrap To Fit off, choose the toggle button again.

### Entering Special Characters

Different systems often use certain key combinations to insert special characters. In some instances, a key combination may be reserved by Text Editor. For example, a Text Editor mnemonic for displaying a menu might conflict with a key sequence you want to use on your keyboard.

To insert the correct character you may need to override the reserved behavior by preceding the key combination with Control+Q.

## Moving the Cursor in a Document

As you enter and edit text, you move the insertion cursor using the mouse and keyboard cursor keys. Using the mouse, move the pointer to the new location in the document and click mouse button 1.

You can also use the keyboard cursor movement keys:

`Key` | `Cursor Movement`
Up Arrow | Up one line
Down Arrow | Down one line
Left Arrow | Left one character
Right Arrow | Right one character
Control+Left Arrow | Move left to previous word
Control+Right Arrow | Move right to next word
Home | Beginning of the current line
End | End of the current line
Control+Up Arrow | Beginning of the previous paragraph
Control+Down Arrow | Beginning of the next paragraph
Control+Home | Beginning of the document
Control+End | End of the document
Control+G | To the Line field in the status line

If your keyboard uses different key labels, ask your system administrator to identify the corresponding keys.

### To Go to a Specific Line

1. Display the status line (see UG.TextE.mkr.4).

2. Press Control+G or click in the Line field of the status line.

3. Type the line number you want to go to and press Return.

### To Scroll a Document

1. Select and drag the vertical scroll bar to view more text. Use the horizontal scroll bar to view long lines.

   You can also use the scrolling keys:

   `Key` | `Scroll Movement`
   Page Up | Up one page
   Page Down | Down one page
   Control+Page Up | Left one page
   Control+Page Down | Right one page

## Selecting Text

Before using edit commands such as cut and paste, you must select the text. You can select text using the mouse or the keyboard.

### To Select Text with the Mouse

1. Click at the beginning of the text you want to select.

2. Press and hold mouse button 1 and drag to the end of the text.

To deselect text, click any area in the window.

To modify a selection you have made, press and hold the Shift key and mouse button 1. Then drag forward or backward to adjust the amount of selected text. Or, hold down the Shift key and one of the arrow keys to change the selection.

You can also use these shortcuts for selecting text:

Word | Double-click the word
Line | Triple-click the line
All text | Quadruple-click in the text

### Secondary Selection

This method enables you select text and replace it with another selection, which is used as the replacement text.

#### To Replace Text Using Secondary Selection

1. Select the text that you want to replace.

2. Move the pointer to the beginning of the text you want to replace the first selection with. Hold down the Alt key and mouse button 2 and drag to the end of the text you want to use.

   The text is underlined.

   If your keyboard does not have an Alt key, ask your system administrator to identify the corresponding key.

3. Release the Alt key and mouse button.

   The underlined text overwrites your first selection.

### To Select Text with the Keyboard

Text to Select | Action
Text block | Move the cursor to the beginning of the text block. Hold down the Shift key and an arrow key to move the cursor to the end of the text block.
Cursor to beginning of line | Shift+Home
Cursor to end of line | Shift+End
Cursor to beginning of paragraph | Shift+Control+Up Arrow
Cursor to end of paragraph | Shift+Control+Down Arrow
Cursor to beginning of document | Shift+Control+Home
Cursor to end of document | Shift+Control+End
All text | Control+/
Deselect all text | Control+\

## Editing Text

Minor edits can be made using the editing keys. You may also want to copy, move, or delete portions of text, find and change a word or phrase, or check the spelling of your document.

### Editing Keys

`Key` | `Action`
Backspace | Deletes the character before the cursor
Delete | Deletes the character following the insertion cursor
Control+Backspace | Deletes the previous word
Shift+Backspace | Deletes characters from the cursor to the beginning of the line
Control+Delete (Control+Remove) | Deletes all the characters from the cursor to the end of the current line
Insert | Toggles Overstrike and Insert mode

Note that not all vendors' keyboards supply these keys. Please see your local vendor's documentation for alternate key bindings.

### Menu Shortcut Keys

You can also use these shortcut keys when making edits.

Control+C | Copy selected text
Control+X | Cut selected text
Control+V | Paste selected text
Control+F | Find/Change text
Control+Z | Undo a cut, delete, clear, include, copy, or paste command

### UNIX Key Bindings

UNIXTM key bindings enable you to use a set of extended Emacs keys, such as Alt+B (back word) or Control+N (next line), in Text Editor. To enable UNIX key bindings (which are set off by default) you edit a file in your home directory.

#### To Enable UNIX Key Bindings

1. Add the following line to the `.Xdefaults` file in your home directory:

       #include “/usr/dt/app-defaults/language/UNIXbindings”

   Replace language with the name of your language environment.

   If the `.Xdefaults` file does not exist, create the file in your home directory.

2. Log out of your current session.

3. Log in and restart Text Editor.

Some Text Editor menu accelerators conflict with UNIX key bindings. When UNIX key bindings are enabled, Text Editor provides alternate menu accelerators for these commands:

Command | Alternate Menu Accelerator
Find/Change (Control+F) | Control+S
Paste (Control+V) | Shift+Insert
Print (Control+P) | no alternate accelerator
Undo (Control+Z) | Control+_

If you want to modify these menu accelerators, copy the contents of the `/usr/dt/app-defaults/` language`/UNIXbindings` file into your `.Xdefaults` file and then make your changes.

When using UNIX key bindings, the Delete key deletes the previous character rather than the character that follows the cursor.

### To Set Overstrike Mode

As you type, new characters are inserted. If you want to type over existing characters, change to Overstrike mode.

- Choose Overstrike from the Options menu. To return to Insert mode, choose Overstrike again from the menu.

- Or, use the Insert key to switch between Insert and Overstrike mode.

  When Overstrike mode is on, the cursor changes to a block. If you use Overstrike mode often, you may want to display the status line (see UG.TextE.mkr.4) because it indicates whether Overstrike mode is on or off.

### To Type Over Text

1. Select the text.

2. Type the replacement text.

   You can also choose Overstrike from the Options menu to turn off Insert mode and type over the text directly.

### To Delete Text

1. Select the text.

2. Choose Delete from the Edit menu or press the Delete key.

Deleted text cannot be pasted, but it can be recovered with the Undo command (see UG.TextE.mkr.11).

If you intend to paste the text that you delete, use the Cut command (see UG.TextE.mkr.12).

### To Clear Text

The Clear command replaces the selected text with spaces or blank lines.

1. Select the text to be cleared.

2. Choose Clear from the Edit menu.

### To Undo an Edit

1. Choose Undo from the Edit menu or press Control+Z.

   Undo reverses the last cut, paste, clear, delete, change, include, or format operation.

### To Copy Text

1. Select the text to be copied.

2. Choose Copy from the Edit menu or press Control+C.

   A copy of the text is stored on a clipboard where it can be accessed or replaced by other applications.

3. Click where you want to insert the text.

4. Choose Paste from the Edit menu or press Control+V.

   You can also use drag and drop to copy text (see UG.TextE.mkr.15).

Use this shortcut to copy a word or phrase: Select the text, move the pointer to where you want to insert the text, and click mouse button 2. This is a quick way to copy text into a dialog box.

### To Move Text (Cut and Paste)

1. Select the text.

2. Choose Cut from the Edit menu or press Control+X.

   The text is erased from the document and stored on a clipboard where it can be accessed or replaced by other applications.

3. Move the cursor to where you want to insert the text.

4. Choose Paste from the Edit menu or press Control+V.

   You can also use drag and drop to move text (see UG.TextE.mkr.14).

### To Correct Misspelled Words

1. Choose Check Spelling from the Edit menu.

   The Spell dialog box lists misspelled or unrecognized words.

   #### Spell dialog box

2. Select the misspelled word in the Misspelled Word list that you want to find and press Return. Or, just double-click the word.

   The next occurrence of the word is highlighted in your document.

3. Type the correct word into the Change To field.

4. Click Change to correct a single occurrence.

5. To find and change additional occurrences, click Find and then Change.

   Or, click Change All to replace all occurrences.

6. Click Close when you are done.

The Check Spelling feature is only available for the English language.

### To Include a File

You can insert a text file into your document using a menu command or by dragging a file icon into the Text Editor window (see UG.TextE.mkr.16).

1. Position the cursor where you want to insert the text file.

2. Choose Include from the File menu.

   The Include a File dialog box lists files and folders on your system. You can browse the documents listed, or change to a new folder to locate other files on your system.

   #### Include a File dialog box

3. Select the document you want to insert in the Files list.

4. Press Return or click OK.

## Using Drag and Drop

You can use drag and drop to move or copy text between Text Editor documents or other applications. You can also include a file into your document using drag and drop.

### To Move Text Using Drag and Drop

1. Select the text that you want to move.

2. With the pointer on the selection, press and hold mouse button 1, and drag to where you want to insert the text.

3. Release the mouse button.

   The text is inserted into your document relative to the position of the drag icon.

### To Copy Text Using Drag and Drop

1. Select the text you want to copy.

2. With the pointer on the selection, press and hold the Control key and mouse button 1, and drag to where you want to copy the text.

3. Release the Control key and mouse button.

   The text is copied relative to the position of the drag icon.

### To Include a File Using Drag and Drop

When using drag and drop, the contents of the file are copied into the Text Editor window at the position of the insertion cursor. The original file remains intact.

1. Click in your document where you want to include the file.

2. Drag the file icon that you want to include into the Text Editor window.

## Searching a Document

You can search for a word or phrase in your document. The Find command begins from the position of the insertion cursor and proceeds through the entire document. You can automatically replace or delete occurrences found in your document.

Searches are case sensitive. To find all occurrences, search for both lowercase and uppercase instances.

### To Find Text

1. Choose Find/Change from the Edit menu or press Control+F.

   #### Find/Change dialog box

2. Type the text you want to find in the Find field.

3. Press Return or click the Find button to locate the next occurrence of the text.

4. To find additional occurrences, press Return or click Find again.

### To Find and Change Text

1. Choose Find/Change from the Edit menu or press Control+F.

2. Type the text you want to find in the Find field.

3. Type the replacement text in the Change To field.

4. Press Return or click the Find button to locate the next occurrence of the text.

5. Click Change to replace a single occurrence.

6. To find and change additional occurrences, click Find and then Change.

   Or, click Change All to replace all occurrences.

   There is no Undo for Change All.

7. Click Close when you are done.

### To Find and Delete Text

1. Choose Find/Change from the Edit menu or press Control+F.

2. Type the text you want to delete in the Find field.

3. Leave the Change To field blank.

4. Press Return or click Find to locate the next occurrence.

5. Click Change to delete a single occurrence.

6. To find and change additional occurrences, click Find and then Change.

   Or, click Change All to replace all occurrences.

7. Click Close when you are done.

## Formatting and Printing Documents

Once your editing is complete, format your document by choosing margins and text alignment.

### To Format a Document

1. Choose Settings from the Format menu.

   #### Format Settings dialog box

2. Enter margins.

   The default left margin is 0 and the right margin is dynamically set to the width of the Text Editor window. Margins are specified as a number of character columns.

3. Select left, right, justify (block style), or center alignment.

4. Determine the scope of the formatting:

   - To format a single paragraph, place the cursor in the paragraph, then click Paragraph.

   - To format the entire document, click All.

5. After closing the dialog box, choose Paragraph or All from the Format menu to apply the settings.

### To Print an Open Document with Default Options

1. Open the document in Text Editor.

2. Choose Print from the File menu.

### To Print an Open Document with Specific Options

1. Open the document in Text Editor.

2. Choose Print... from the File menu or press Control+P.

   The Print dialog box appears.

   #### Print dialog box

   - To select a different printer, type the new printer name in the Printer Name field.

   - To output multiple copies, type the number of copies in the Copies field.

   - To print to a file, click the Print to File checkbox and type the path and filename for the file.

   - To have long lines wrap to fit the page size, click the Use Word Wrap checkbox.

   - To set the margins for the printed output, type the desired values in the Top, Left, Right, and Bottom fields. You can specify margin values in inches (in), centimeters (cm), or pixels (pi). The default value for all margins is one inch. If no unit value is specified, pixels are used.

     Your margin settings remain in effect until you change them. They are used when you print with default options.

   - To include headers and/or footers on the printed output, choose the type of information you want for Top Left, Bottom Left, Top Right, and/or Bottom Right. For each position, you can select:

     - `Date`, to display the current date.

     - `Document Name`, to display the name of the document being printed.

     - `Page Number`, to display page numbers.

     - `User Name`, to display your user name.

     - `None`, to display nothing.

     The following defaults are used:

     - `Top Left`—None

     - `Top Right`—Document Name

     - `Bottom Left`—None

     - `Bottom Right`—Page Number

     Your header and footer settings remain in effect until you change them. They are used when you print with default options.

3. To set printer-specific options, click the Setup... button on the Print dialog box. The Print Setup window appears. From this window, you can access both Printer and Job options.

   #### Print Setup window

   The Printer options dialog box lets you control such items as page orientation (portrait or landscape), page size (legal, letter, etc.), one- or two-sided printing, and which printer tray to use.

   The Job options dialog box lets you indicate whether you want an email notification sent when your print job completes and what text (if any) you want to appear on the banner page. You can also specify print command options in the Print Command Options field.

   When finished with the Print Setup window, click OK to set your changes and return to the Print dialog box.

   Your Print Setup settings remain in effect until you change them. They are used when you print with default options.

4. To send the open document to the printer from the Print dialog box, click Print.

### To Print a Closed Document

1. Display the document's file icon in File Manager.

2. Drag the file icon to the Printer control in the Front Panel.

   The Print dialog box is opened.

3. Optional. Set printing options.

4. Click Print.

## Recovering a File

If Text Editor is interrupted due to a system error, it attempts to save your changes in a recovery file in your current folder. The recovery file is named `#` filename`#`, where filename is the name of the document. If you had never named your document, the recovery file name is `#UNTITLED#.`

### To Recover a File

1. Start Text Editor.

2. Open the recovery file.

3. Save the document using your original file name or provide a new name for a previously unsaved document.

## Text Editor and Other Applications

Other applications can use Text Editor as a tool to edit documents or other types of information. Under certain conditions, an application may choose to restrict your editing choices. In the example below, the File menu has been modified. The Save As command has been replaced with a Copy To File command and the New and Open commands are not available.

### Text Editor with modified File menu