Creating & Editing Files with pico
Although it's easy to use a GUI text editor in Mac OS X, it's a good idea to know a little about Unix text editors and how they work. This way, if you ever find yourself sitting in front of a Unix system, you'll have a chance at making it usable.Unix offers a number of text editors: the easy-to-use pico, the ever-present vi, and the geek-favorite emacs. Which one you use is a personal decision: Each has strengths and weaknesses. It is far beyond the scope of this chapter (or book) to help you master any one of these, let alone all three. Because pico is the easiest Unix text editor to use, I'll introduce it here.
- The emacs and vi text editors are so powerful and complex that entire books have been written about them. You can learn a little more about them in their somewhat inadequate man pages; type man emacs or man vi and press

To open a file with pico
Type pico file (for example, pico sample.txt) and press

Figure 34.
pico can open an existing file…[View full size image]

Figure 35. …or create a new one with the name you specify.
[View full size image]

To use pico menu commands
Press the keystroke for the command you want. Each command includes


Figure 36. The beginning of
pico's onscreen help.[View full size image]

To navigate through text
To move one character in any direction, press the corresponding arrow key.Or To move to the previous or next page, press


To insert text
1. | Position the cursor where you want to insert character(s) (Figure 34 ). |
2. | Type the character(s) you want to insert. The new text is inserted (Figure 37 ).Figure 37. Text is inserted at the cursor.[View full size image] ![]() |
To delete text
1. | Position the cursor on the character you want to delete (Figure 38 ).Figure 38. Position the cursor on the character you want to delete.[View full size image] ![]() |
2. | Press ![]() Figure 39. Text at the cursor is deleted.[View full size image] ![]() |
To cut & paste text
1. | Use the arrow keys to position the cursor at the beginning of the text you want to cut (Figure 34 ). |
2. | Press ![]() Figure 40.[Mark Set] appears in the window.[View full size image] ![]() |
3. | Use the arrow keys to position the cursor at the end of the block you want to cut. Text between the starting point and cursor turns black (Figure 41 ).Figure 41. Use the arrow keys to select text.[View full size image] ![]() |
4. | Press ![]() Figure 42. Using the Cut Text command removes the selected text.[View full size image] ![]() |
5. | Position the cursor where you want to paste the text (Figure 43 ).Figure 43. Position the cursor where you want to paste the text.[View full size image] ![]() |
6. | Press ![]() Figure 44. Using the Uncut Text command pastes the text back into the document.[View full size image] ![]() |
- [Mark Set] (Figure 40 ) indicates that you have marked the beginning of a text selection.
To insert an existing file
1. | Position the cursor where you want to insert the file (Figure 34 ). |
2. | Press ![]() |
3. | The Insert file prompt appears at the bottom of the window. Enter the path name for the file you want to insert (Figure 45 ) and press ![]() Figure 45. Enter the name of the file you want to insert at the Insert file prompt.[View full size image] ![]() Figure 46. The file is inserted at the cursor.[View full size image] ![]() |
To save changes to a file
1. | Press ![]() Figure 47. Use the File Name to write prompt to enter a name for the file.[View full size image] ![]() |
2. | To save the file with the same name, press ![]() ![]() ![]() |
To exit pico
1. | Press ![]() |
2. | If you have made changes to the file since opening it, the Save modified buffer prompt appears at the bottom of the window (Figure 48 ).
![]() ![]() ![]() ![]() Figure 48. The Save modified buffer prompt enables you to save changes to the file before you exit pico.[View full size image] ![]() |