Solaris Common Desktop Environment: User's Guide

Chapter 10 Using Text Editor

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

Opening and Closing Text Editor

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

To Open Text Editor

  1. Open the Applications subpanel in the Front Panel and click the Text Editor control.

    Graphic

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.


Note -

If the path /usr/dt/bin has not been set in your .cshrc file, then type /usr/dt/bin/dtpad to run Text Editor from the command line.


To Close Text Editor

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


Note -

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).

Figure 10-1 Text Editor window

Graphic

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.

Graphic

    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.

You can choose that Text Editor maintains a file containing the previously saved version of a file each time it performs a save during the current session.

To Create a New Document

A new document named (UNTITLED) is created when you start Text Editor. To enter text in your document, see "Entering Text". You provide a new file name when you save the document.

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

    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 set off, the dialog box omits this choice (see "Using Wrap To Fit").

    Figure 10-2 Save As dialog box

    Graphic

  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.


Note -

To save your document to a diskette that has been mounted, choose /floppy/floppy_name through the menu button at the end of the text field, Enter path or folder name. Type a name in the Enter file name text field and click OK.


To Save a Document to the Original File

    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 "Using Wrap To Fit").

Opening an Existing Document

You can open an existing document in these ways:

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.

    Figure 10-3 Open a File dialog box

    Graphic

  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.


    Note -

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



    Note -

    To save a file from a CD-ROM or diskette that has been mounted, choose /cdrom/cd_name or /floppy/floppy_name through the menu button at the end of the text field, Enter path or folder name. Select the file name and click OK.


To Open an Existing Document from File Manager

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

    Figure 10-4 Document file icon

    Graphic

  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.

Working with Backup Versions

You can choose that Text Editor maintains a file containing the previously saved version of a file each time it performs a save. You do this using the Backup on Save menu item on the Options menu. The default setting is un-selected, so each time you run Text Editor, the setting reverts to the default.

When performing a save with Backup on Save selected, Text Editor first copys the original file to a new file name (the old file name with a percent character "%" appended), and then saves the edited file to the original file name.

To Recover the Backup Version of a File

You can revert to the previously saved version of a file in which you are interested as follows:

  1. Choose Open from the File menu.

    Text Editor displays the Open a File dialog.

  2. Browse to the folder containing the file in which you are interested, and select the corresponding file name with a percent character "%" appended.

    Text Editor opens the file.

  3. Use the Save As command in the file menu to overwrite the original file.

    The original file now contains the contents of the previous version.

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 "To Set Overstrike Mode").

To Enter New Text

    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 discard the dynamic line endings. When you save your document, you choose one of these options:

To Set Wrap To Fit On or Off

    To set Wrap To Fit on, choose Wrap To Fit in the Options menu. To set Wrap To Fit off, choose it from the menu again.

Entering Special Characters

Different systems often use certain key combinations to insert special characters (see "Composing 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 


Note -

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 "To Display the Status Line").

  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

    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.


    Note -

    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.


    Note -

    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 

Deletes all the characters from the cursor to the end of the current line 

Insert 

Toggles Overstrike and Insert mode 

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

UNIX® 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.


    Note -

    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.

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 "To Undo an Edit").

    If you intend to paste the text that you delete, use the Cut command (see "To Undo an Edit").

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

    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 "To Copy Text Using Drag and Drop").


    Note -

    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 "To Move Text Using Drag and Drop").

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 "To Include a File Using Drag and Drop").

  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.

    Figure 10-5 Include a File dialog box

    Graphic

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

  4. Press Return or click OK.


Note -

To include a file from a CD-ROM or diskette that has been mounted, choose /cdrom/cd_name or /floppy/floppy_name through the menu button at the end of the text field, Enter path or folder name. Select the file name and click OK.


Correcting Misspelled Words

You can correct misspelled words with the Spelling Checker. You can also customize your Personal Dictionary and Main Dictionary; see "To Correct Misspelled Words" for more information.

To Correct Misspelled Words

  1. Choose Check Spelling from the Edit menu.


    Note -

    Your Spelling Checker dialog box may look different than the one pictured in Figure 10-6. If so, go to Figure 10-7 and follow the instructions after that figure.


    The Spell dialog box lists misspelled or unrecognized words.

    The Check Spelling (Version 1) feature is only available for the English language.

    Figure 10-6 Spell dialog box - Version 1

    Graphic

  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.

    Or, click Change All to replace all occurrences.

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

  6. Click Close when you are done.


    Note -

    If your Spelling Checker dialog box resembles Figure 10-7, follow the instructions after the figure.


    The Spelling Checker dialog box displays a misspelled or unrecognized word and lists suggestions. To start a new spelling check while the Spelling Checker dialog box is open, click Start Check.

    Figure 10-7 Spelling Checker dialog box - Version 2

    Graphic

  1. Take action on the first word found by the spelling checker:

    • If the suggested replacement is correct, click Change to correct this occurrence, or Change All to change all occurrences. (You cannot Undo a Change All.)

    • If you see the correct replacement in the list, select it and click Change or Change All.

    • If the correct replacement is not in the list, type it in the suggestion field and click Change or Change All.

    • If the word is correct and you want to add it to your Personal Dictionary, click Learn Word.

    • If the word is correct but you do not want to add it to your Personal Dictionary, click Skip to skip this occurrence, or Skip All to skip all occurrences.

  2. Continue through the misspelled words found by the Spelling Checker.

  3. To stop the Spelling Checker and leave the dialog box displayed, click Stop Check.

    To stop Spelling Checker and close the dialog box, click Close.

Customizing Spelling Checker Dictionaries

When you run Spelling Checker, it uses both your Personal Dictionary and Main Dictionary. You can edit your Personal Dictionary and set your Main Dictionary.

You can run Spelling Checker with or without your Personal Dictionary. You can also remove words from your Personal Dictionary, import another user's Personal Dictionary, and export your Personal Dictionary to make it accessible to other users. When you import another user's Personal Dictionary, you can choose whether you want to append the imported Personal Dictionary to your own Personal Dictionary, or overwrite your own Personal Dictionary with the imported one.

Spelling Checker automatically sets your Main Dictionary to the default locale installed on your system. You can change the Main Dictionary to a different locale whenever Spelling Checker starts or change the locale just for the current session.

To Run Spelling Checker Without Your Personal Dictionary

  1. Click Options in the Spelling Checker dialog box.

  2. Choose Personal Dictionary as the Category.

    Figure 10-8 Personal Dictionary dialog box

    Graphic

  3. Deselect the Use Personal Dictionary checkbox.

  4. Click OK to save your changes and close the dialog box.

    Spelling Checker will now run only with your Main Dictionary.

To Remove a Word From Your Personal Dictionary

  1. Click Options in the Spelling Checker dialog box.

  2. Choose Personal Dictionary as the Category.

  3. Select the word in the scrolling list.

    To select more than one word, select the first word and then Shift-Click (or Control-Click) to choose the other words. You can drag choose contiguous words.

  4. To delete the word from the list, click Remove.

  5. To save your changes and close the dialog box, click OK.

To Import Another User's Personal Dictionary

  1. Click Options in the Spelling Checker dialog box.

  2. Click Import in the Spelling Checker Options dialog box.

    The Spelling Checker Import dialog box is displayed.

    Figure 10-9 Personal Dictionary Import dialog box

    Graphic

  3. Select the dictionary you want to import in the Files list, or type the dictionary name in the Selection field.

  4. Press Return or click OK.


    Note -

    You can also double-click the dictionary name in the dialog box.


  5. In the dialog box that appears, choose whether you want to append the imported personal dictionary to your own personal dictionary, or overwrite your own personal dictionary with the imported one.

To Export Your Personal Dictionary

  1. Click Options in the Spelling Checker dialog box.

  2. Click Export in the Spelling Checker Options dialog box.

    The Spelling Checker Export dialog box is displayed.

    Figure 10-10 Personal Dictionary Export dialog box

    Graphic

  3. Select the dictionary you want to export in the Files list, or type the dictionary name in the Selection field.

  4. Press Return or click OK.


    Note -

    You can also double-click the dictionary name in the dialog box.


    Now other users can import your dictionary. You can send your personal dictionary to another user or tell them where it is in your file system.

To Set Your Current Dictionary Locale

  1. Click Options in the Spelling Checker dialog box.

  2. Choose Main Dictionary as the Category.

    The Main Dictionary dialog box is displayed.

    Figure 10-11 Main Dictionary dialog box

    Graphic

  3. Choose the desired locale as the Current Dictionary.


    Note -

    This locale setting is for the current Spelling Checker session only. The next time you restart Spelling Checker it will run with your default locale.


  4. To save your changes and close the dialog box, click OK.

To Set Your Default Dictionary Locale

  1. Click Options in the Spelling Checker dialog box.

  2. Choose Main Dictionary as the Category.

  3. Determine your main dictionary locale:

    • To have your Main Dictionary match the default locale installed on your system, select Set Dictionary to Match Locale Language.

    • To override the system default locale, Set Dictionary To and choose the desired locale.

  4. To save your changes and close the dialog box, 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.

    Figure 10-12 Find/Change dialog box

    Graphic

  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.


    Caution - Caution -

    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.

    Figure 10-13 Format Settings dialog box

    Graphic

  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

  1. Open the document in Text Editor.

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

    The Print dialog box displays the name of your system's printer and enables you to set printing options. By default, your document is printed on your system printer. If desired, you can direct your job to a different printer.

    Figure 10-14 Print dialog box

    Graphic

  3. Optional. Set any of these printing options:

    • Type the number of copies to print.

    • Type text to appear on the printer banner page.

    • Click Print Page Numbers if you want to number the pages.

    • Type command-line printer options.

  4. Click Print.

    The Print dialog box closes when you print your document. To close the dialog box without printing your file, click Cancel.

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.

Figure 10-15 Text Editor with modified File menu

Graphic

Using Text Note

When you click the Text Note control on the Front Panel, Text Editor opens in note mode; this enables you to type some text and post it on the Workspace for fast retrieval. If you exit Text Editor while it is in note mode, the text note is saved in your home folder and displayed as an icon on the Workspace backdrop. You can reopen a text note by double-clicking its icon on the Workspace.

To Type a Text Note
  1. Click the Text Note control on the Front Panel.

    Text Editor is opens in note mode.

  2. Type your note.

  3. Choose Close from the File menu.

    The Save dialog box is displayed.

  4. Choose Yes to save changes.

    The text note is put on the Workspace.

To Put a Note on the Workspace

    Exit Text Editor while you are editing the text note, making sure you choose to save current changes if prompted by the Save dialog box.

    The note icon is displayed in the upper right corner of the workspace.

To Remove a Note from the Workspace

    Double-click the text note icon on the Workspace.

File Naming

Text notes are saved as files in your home directory using file names derived from the first twenty characters of the note. For example, if our fictional user Fred Jones had a note containing the text Reminder: Call John Smith about meeting, it would be saved in the file /home/fredj/Reminder: Call John .