410 - Use PICO to Edit Text in Linux/UNIX

PICO is a quick and efficient text editor for composing mail messages and for creating and modifying UNIX files. One advantage of PICO over other editors is that typed words are automatically wrapped from one line to the next, which is helpful for composing messages - but beware of that feature if you use PICO for writing computer programs.

If you use the PINE email program, you are automatically placed in PICO when you select the Compose and Send a Message option or when you reply to a received message.

To create a text file or to edit an existing text file, at the UNIX prompt ($) type:

pico filename 

where filename is the name of the file you want to create or the file you want to edit. Press <Enter> (<return> on a Macintosh) after each command.

If you open PICO and UNIX doesn't know what type of terminal you are on, you will see a message similar to:

Incomplete termcap entry

If so, at the UNIX prompt ($) type:

source .login

(Don't forget the period before the word login.)

Press <Enter> (<return>) . Then type:

pico filename

The PICO screen will appear. The status line at the top of the screen (to the left) indicates which version of PICO you are currently using, and (at the center) the name of the file you are editing. You can begin by typing text. PICO displays up to 19 lines on the screen at one time.

PICO Commands

The bottom two lines in the PICO screen list Quick Command keys. PICO commands are used in conjunction with the Control key (<Ctrl> or <control> on a Macintosh), represented on the screen by the caret (^). The Control key is used like the Shift key; press and hold the Control key and then press the next character. For example, <^x> (<Ctrl+x> or <control+x>) means you should press and hold the Control key and then press the x key.

Moving the Cursor

  • <^b> or <left arrow> moves left one character.
  • <^f> or <right arrow> moves right one character.
  • <^p> or <up arrow> moves up to previous line.
  • <^n> or <down arrow> moves down to the next line.
  • <^a> moves to beginning of line .
  • <^e> moves to end of line.
  • <^v> moves page down.
  • <^y> moves page up (previous page).
  • <^l> redraws the current screen.

Deleting Text

  • <backspace> erases the character to the left of the cursor.
  • <^d> deletes the character at the cursor position.
  • <^k> deletes the entire line at the cursor position.
  • <^u> undeletes (restores) the last line(s) deleted and places them at the cursor position.

Saving a File

  • <^x> saves and exits PICO.
  • <^o> saves as you are editing; allows you to change the file's name.

Other Useful Commands

  • <^t> spell checks your text
  • <^w> searches for text (i.e. “Where is?”). At the Search prompt, enter text in uppercase or lowercase.
  • <^r> reads in a file from your home directory .
  • <^g> accesses the online help. (<^x> exits help.)
  • <^j> justifies paragraph.

To open a file in your UNIX directory press <Ctrl+r> (<control+r>). At the prompt File to insert from home directory, type the name of the file and press <Enter> (<return>). Or, press  <Ctrl+t> (<control+t>) to select the To Files option from the <^r> submenu. Use the arrow keys to highlight the name of the file to be read and press <Enter> (<return>).

Save a File in PICO

When you finish editing your file, press <^x> to exit PICO. You will see this message:

Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES)?

Press the <y> key to save the file with your changes. PICO then prompts with:

File Name to Write: filename.

Press <Enter> (<return>) to keep the original filename.