The Pico Editor
What is Pico?
Pico is a text editing program used with Unix and Unix-based programs. Because of its ease of use, it is the editor of choice for simple documents. It is also very similar to the default text editor used in the Pine e-mail program.
One nice feature of Pico is that almost all of the editing commands are displayed at the bottom of the editing screen for easy reference. And, even though it is easy-to-use, Pico has a few advanced features too (e.g., cut and paste capability, a spelling checker).
Pico is a "text-only" editor. That is, it does not support features such as different font sizes and types, variable margins, graphics, etc., that are found in true word processor programs.
Comment on Notation: Within this webpage, brackets "< >" indicate keys to be pressed. Thus, the instruction press means to press the letter "m" key.
To start the Pico editor, first exit the menu system (if you are using the menu) and get to the command prompt. At the command prompt, enter the command pico or pico filename, where filename is the name of a new or existing file you wish to edit. The Pico editing screen will be displayed, similar to the one shown below.
The Pico Editing Screen
UW PICO(tm) 3.3 New Buffer
^G Get Help ^O WriteOut ^R Read File ^Y Prev Pg ^K Cut Text ^C Cur Pos
The Pico editing screen consists of four components:
- The status lineat the very top of the screen displays three pieces of information.
- At the far left end of the line you see Pico's version number.
- At the far right you will see the word Modified displayed if you have made editing changes that have not yet been saved. (For information on Saving)
- And, in the middle you will see the name of the file you are editing, or you will see the words New Buffer if you have not yet specified a name for the file you are editing.
- The large area in the middle of the screen is the editing buffer(editing area).
- This is where the text you type and edit will be displayed.
- This area is blank in the sample screen shown above.
- The bottom two lines list the available editing commands. These are discussed in the Editing Section.
- The line just above these editing commands (third line from the bottom of the screen) is usually blank. It is used to occasionally report informational messages and to prompt you for input.
The initial content of the editing buffer depends on how you launched Pico:
- If you launched Pico from the menu or from the command prompt using the command pico, but without specifying a file to edit:
- The buffer will be blank.
- You can simply begin typing if you wish to create a new file.
- If, instead, you wish to edit one of your existing files, you will have to insert that file into the blank buffer (as described in the section Inserting A File).
- If you launched Pico from the command prompt using the command pico filename:
- The buffer will contain the text of the file you specified.
- Of course, if that file is empty or has not yet been created, the buffer will be blank.
After you have started the editor, you may begin typing new text into the editing buffer or changing existing text.
Use the arrow keys to position the cursor, as needed.
Any new text you type will be inserted at the current cursor location. If there is any existing text to the right of the cursor or below it, that text will be pushed ahead as needed to make room for the newly inserted text.
You do not have to press <Enter> when your typing reaches the right margin. Simply keep typing, and Pico will move you down to the next line automatically. You only need to press <Enter> when you want to end a paragraph and begin a new one or when you want to create one or more blank lines.
Pressing the <Backspace> key will delete text that is to the left of the cursor, one character at a time.
Additional editing functions are discussed below.
The subsections below explain how to use the various editing functions that are available in Pico, such as searching for text and using the spelling checker. These functions are initiated by issuing a command to Pico. Almost all of the available commands are listed at the bottom of the editing screen for easy reference. All commands, including those not listed in the editing screen, are explained in the Pico Help document.
Pico commands are issued using the <Ctrl> key. In the command listings at the bottom of the screen, the <Ctrl> key is denoted by the "^" caret symbol. For example, the notation "^G" means "hold down the <Ctrl> key and press "g". To be consistent with the notation used in our other information takeouts, in this document we will refer to such a key sequence as <Ctrl-g>.
Note: In the discussion below, when we refer to the current line, we mean the line of text in which the cursor is currently located.
- Press the arrow keys to move the cursor through the text, one character or one line at a time.
- To move to the beginning of the current line, press <Ctrl-a>.
- To move to the end of the current line, press <Ctrl-e>.
- If the file you are editing contains many lines (more than will fit on the screen), you can scroll up and down through the text by pressing <Ctrl-y> and <Ctrl-v>, respectively.
- Mnemonic tip: "y" is above "v" on the keyboard.
- To move to the first line of the entire file, press <Ctrl-w> and then <Ctrl-y>.
- To move to the last line of the entire file, press <Ctrl-w> and then <Ctrl-v>.
- To search for text in the file, press <Ctrl-w> (as in "where is"). When prompted, type the text to search for and press <Enter>.
- To find the same text again, press <Ctrl-w> and then press <Enter>. Pico will remember what text you were searching for.
- Pico does not distinguish between upper and lower case letters when searching for text.
- Sometimes the text within a paragraph can become misaligned with the margins, especially if you have done extensive deleting.
- To reformat the paragraph, place the cursor anywhere within the paragraph and press <Ctrl-j>. This will justify the lines so that they properly align with the left and right margins.
- Pico has a limited spelling checker: it will find misspelled words, but it will not suggest the proper spellings.
- To launch the spelling checker, press <Ctrl-t>.
- Pico will find the first word (alphabetically) that it thinks is misspelled and prompt you for the correct spelling.
- Do one of the following:
- To leave the word unchanged, simply press <Enter>. Pico will ignore that word and will then find the next misspelled word.
- To correct the spelling, press the <Backspace> key to erase the incorrect letters, as needed. Then retype the word correctly and press <Enter>. Pico will then find the next misspelled word.
- If you wish to stop (cancel) the spelling checker, press <Ctrl-c>.
- After you correct the spelling of a word and if there is another occurrence of the same misspelled word, Pico will find it and ask you whether to apply the same correction. Answer yes or no, as desired.
- Important Note: Whenever you instruct Pico to leave a word spelled as is, Pico will ignore any other occurrences of that misspelled word that might be in the file.
You can "cut" (delete) an entire line of text or a block of text and then "paste" (re-insert) that text back into the file at any location, if desired.
- Cutting Out Text
- To cut the entire current line, press <Ctrl-k>.
- You can also cut a block of text - for example, part of a line, or several consecutive lines, etc.
- First, move the cursor to one end of the block of text (either the beginning or the end) and mark that location by pressing <Shift-Ctrl-6> (that is, while holding down the <Shift> key and the <Ctrl> key, punch the <6> key). The message Mark Set should appear at the bottom of the screen.
- Note: If you press <Shift-Ctrl-6> to mark the beginning of a block but then you change your mind, press <Shift-Ctrl-6> again to cancel the mark.
- Move the cursor to the other end of the block, using the cursor keys or any of the moving and scrolling shortcuts.
- Press <Ctrl-k> to cut out the block.
- Pasting Text
- Reposition the cursor to the desired location and press <Ctrl-u>. The restored text will be inserted just to the left of the current cursor position.
- Pico "remembers" the cut text until you cut something else. Thus, after you cut a line or block, you may paste it back several times and at different locations, if desired.
When you edit an existing file with Pico, a copy of the file's text is created and displayed in the editing buffer. Thus, any editing changes you make are only made to this copy. The original file remains unchanged until you instruct Pico to perform a save operation (also called a write operation) to save the revised text back into the original file.
The same is true if you are creating a new file. The text you type and edit is not saved into the new file until you perform a save operation.
As you exit Pico, you will be given an opportunity to perform a save, as will be explained below.
It sometimes happens that you are forced out of Pico involuntarily, before you are able to exit normally and save your changes (say, if the electric power goes off or if the computer somehow gets "stuck", etc.). Because of such possibilities, Pico provides a way for you to save the revised text while you are still in Pico, as described below. It is good practice save your changes after every 10 minutes or so of editing, so that if a calamity does occur you will have lost no more than 10 minutes of work.
To save, first press <Ctrl-o>. You will be prompted, in one of two ways, to name the file into which to save the text:
- If you have previously specified a file name to Pico (and you'll know this because the name will be displayed in the status line at the top of the screen), that name will displayed for you in the prompt. You can simply press <Enter> to save to that file, or you can erase the name (using the <Backspace> key) and type another.
- If you have not specified a file name (the status line will display New Buffer instead of an actual file name), you must type the desired name and press <Enter>.
- File names should be single words: do not include blank spaces.
- They may contain letters, digits, periods, dashes, and underscores.
- Upper/lower case DOES make a difference. For example, "blue" and "Blue" are considered different names.
When you attempt to save to the "current" file, Pico will perform the save without asking if you want to overwrite the file's previous contents. When you save to any other file, Pico will ask your permission before overwriting the file. Answer yes or no, as desired. After the save operation is completed, you will remain in Pico so that you can continue editing. Also, the file name displayed in the status line will be that of the file you just saved (even if a different name was in the status line before the save).
You may insert the contents of any of your files into the editing buffer.
To insert text from a file, first place the cursor anywhere in the line that is just below the desired insertion point. Then press <Ctrl-r> (think of "reading" in the text of the other file). You will be prompted for the name of the other file.
- If you remember the name, type it and press <Enter>.
- If you do not remember the name, press <Ctrl-t>. A listing of your files will be displayed. Use the arrow keys to highlight the desired file in the list, then press <Enter>.
Note that inserting a file does not change the file name that is displayed in the status line at the top of the screen.
Important: When inserting a file, if there is any text already in the editing screen, it will remain there, and the new text will be inserted just above the current line.
When you press <Ctrl-c> , a report is displayed at the bottom of the screen that shows the current cursor position within the file. Both the line number and the character position are reported.
If you press <Ctrl-g>, the Pico Help document will be displayed. This document, which is several screens long, explains all of the features of Pico.
- Press <Ctrl-v> and <Ctrl-y> to scroll forward and backward.
- Press <Ctrl-x> to exit this help document and return to the editing screen.
You can also use Pico to delete, rename, and copy your files.
Press <Ctrl-r> and then <Ctrl-t>, as if you wanted to insert text from another file. This will display the list of your files and directories (if you have any directories).
In this list, you will see a description of each file and directory displayed beside its name. For files, the file's current size is displayed - for example, "23 B" or "40 KB" (here "B" means "bytes" and "KB" means kilobytes). For directories, the notation "dir" is displayed.
Now that the file list is displayed, you can do the following:
- To delete a file, highlight it using the arrow keys and then press the letter <d>. You will be asked twice whether to delete it. Press <y> twice.
- To rename a file, highlight it and then press the letter <r>. The file name will be displayed near the bottom of the screen. Use the <Backspace> key to erase the name and retype it as desired, pressing <Enter> when done.
- To make a copy of a file, highlight it and then press the letter <c>. Near the bottom of the screen you will be prompted to type the name you wish the copy to have. Do so and press <Enter>.
If the file you wish to highlight is in another directory, first highlight that directory and press <Enter>. This will display the directory's contents. Then, highlight the desired file.
Note that when a directory's contents are displayed, one of the items listed will be ".. parent dir". If you highlight this item and press <Enter>, you will be returned to the previous (i.e., parent) directory listing.
When finished, press <e> to exit the file listing screen. Then press <Ctrl-c> to cancel inserting text (unless you really do want to insert text from another file). You will be returned to the editing screen.
When you are finished editing and you wish to exit Pico, press <Ctrl-x>. If you have made editing changes to the text, you will be asked whether you wish to save the revised text. Answer yes or no, as desired (press <y> or <n>). If you answer yes, you will prompted to name the file into which to save the text in one of two ways:
- If you have previously specified a file name to Pico (and you'll know this because the name will be displayed in the status line at the top of the screen), that name will displayed for you in the prompt. You can simply press <Enter> to save to that file, or you can erase the name and type another.
- If you have not specified a file name (the status line will display New Buffer instead of an actual name), you must type the desired name and press <Enter>.
Recall the file naming rules.
When you attempt to save to the "current" file (the file whose name appears in the status line), Pico will perform the save without asking if you want to overwrite the file's previous contents. When you save to any other file, Pico will ask for permission before overwriting the file. Answer yes or no, as desired.
Remember: If you have made editing changes and you do not perform a save operation before you exit Pico, the changes you made will be irretrievably lost!
This article was updated: 08/13/2013