Using pico to edit files

Someday you might want to learn emacs or vi. They are much more powerful editors than pico, but much more complicated, too. I have chosen to explain pico here because it is one of the easiest editors that is universally available and because it is part of the pine e-mail system.

First, open a telnet session to math (see telnetting to math from a PUCC PC)) or get a math xterm window running (see how to get a math xterm on a PUCC PC).

Next, type

pico filename

where the word "filename" can be anything you choose. This command will create a file called "filename" and put it in the directory you were in when you typed "pico filename." After you push RETURN at the end of the "pico filename" line, you will see a screen that looks like:

UW PICO(tm) 2.9                   File: filename

    [You will type stuff in this area.  -S. Bell]

                                  [ New file ]
^G Get Help  ^O WriteOut  ^R Read File ^Y Prev Pg   ^K Cut Text  ^C Cur Pos
^X Exit      ^J Justify   ^W Where is  ^V Next Pg   ^U UnCut Text^T To Spell

This will feel very much like you are in pine sending an e-mail. In fact, it is the same program that pine uses. Go ahead and type away as if you were creating an e-mail message. If you get tired of using the arrow keys and BACKSPACE keys to do all your editing corrections, notice that one of the menu items at the bottom of the page is

^G Get Help

Try typing CONTROL-G (i.e., hold down the CONTROL key and then push a lower case g). You will get a screen that looks like this:

UW PICO(tm) 2.9                   File: filename              Modified

    Pico Help Text

    Pico is designed to be a simple, easy-to-use text editor with a
    layout very similar to the pine mailer.  The status line at the
    top of the display shows pico's version, the current file being
    edited and whether or not there are outstanding modifications
    that have not been saved.  The third line from the bottom is used
    to report informational messages and for additional command input.
    The bottom two lines list the available editing commands.

    Each character typed is automatically inserted into the buffer
    at the current cursor position.  Editing commands and cursor
    movement (besides arrow keys) are given to pico by typing
    special control-key sequences.  A caret, '^', is used to denote
    the control key, sometimes marked "CTRL", so the CTRL-q key
    combination is written as ^Q.

    The following functions are available in pico (where applicable,
    corresponding function key commands are in parentheses).

    ^G (F1)   Display this help text.

    ^F        move Forward a character.
    ^B        move Backward a character.
    ^P        move to the Previous line.
    ^N        move to the Next line.
    ^A        move to the beginning of the current line.
    ^E        move to the End of the current line.
    ^V (F8)   move forward a page of text.
    ^Y (F7)   move backward a page of text.

    ^W (F6)   Search for (where is) text, neglecting case.
    ^L        Refresh the display.

    ^D        Delete the character at the cursor position.
    ^^        Mark cursor position as beginning of selected text.
              Note: Setting mark when already set unselects text.
    ^K (F9)   Cut selected text (displayed in inverse characters).
              Note: The selected text's boundary on the cursor side
                    ends at the left edge of the cursor.  So, with
                    selected text to the left of the cursor, the
                    character under the cursor is not selected.
    ^U (F10)  Uncut (paste) last cut text inserting it at the
              current cursor position.
    ^I        Insert a tab at the current cursor position.

    ^J (F4)   Format (justify) the current paragraph.
              Note: paragraphs delimited by blank lines or indentation.
    ^T (F12)  To invoke the spelling checker
    ^C (F11)  Report current cursor position

    ^R (F5)   Insert an external file at the current cursor position.
    ^O (F3)   Output the current buffer to a file, saving it.
    ^X (F2)   Exit pico, saving buffer.

^X Exit Help                           ^V Next Pg

After you have read this screen, notice that one of the menu items at the bottom is

^V Next Pg

Type CONTROL-V to get the next page of help. Type CONTROL-X to get out of help and back into your editting session.

Most of the editting commands in the help list are self explanatory. One that is not is HOW TO CUT MARKED TEXT. Here's how. Use the arrow keys to move to the first character of text that you want to remove. Type ^^, i.e., type CONTROL-6, to mark the beginning of the text you want to remove. Then use the arrow keys to highlight a range of text. When the text you want to remove is highlighted, just type ^K (CONTROL-K) and the text will go away. (If you don't like what you see, type ^U (CONTROL-U) IMMEDIATELY to uncut the text.)

The text you are typing is saved in a place called a "buffer." (Think of the buffer as a scratchpad.) When you want to put what you see in front of you into a permanent file, you need to "save the buffer." Notice the menu item at the bottom of the screen that says

^O WriteOut

This menu item means that you can save the buffer to the file called filename by typing ^O (CONTROL-O).

If you are creating a large file, it is good practice to type ^O every few minutes to save what you have done so far. (If the computers crash while you are editing a file, you will lose everything you have typed since the last time you "saved the buffer.")

When you are finished creating your file, type ^X (CONTROL-X). Answer y to the question about saving the buffer and then push RETURN when pico gives you a chance to send the buffer to a different filename.

The stuff you typed has now been saved to a file called "filename." To view what you have created, type

more filename

and press the SPACE bar to page through the file. (Type q for QUIT if you get tired of paging before you reach the end of the file.)

After you have quit pico, you can restart it anytime by typing


or by typing

pico filename

If "filename" is a file that already exists, you will find it in your screen when pico starts and you can modify or extend the file as above.

Here are a few UNIX commands that you will want to know about.

ls                        -----this command lists your files
                               in the current directory

rm filename               -----this command removes the file
                               "filename" from your account

mv filename newfilename   -----this command changes the name
                               of the file "filename" to

cp filename newfilename   -----this command makes a copy of
                               the file "filename" and puts
                               it in a file called "newfilename"

Other important commands you will need to learn include

mkdir directory        ---to create a directory
                          called "directory"
rmdir directory        ---to remove (an empty) directory
                          called "directory"
cd directory           ---to change directories
                          to "directory"

To read the online help about a command, use the man command. For example, typing

man mv

will bring up a manual page for the mv command. Push the SPACE bar to scroll down the page. Push q to quit the manual page.

You are now ready to move on to the next section, maple and xmaple

Back to the MATH 2000 HOME PAGE