The pico editor is one of the easiest text editors for new UNIX users to learn, and we will discuss it here. Keep in mind, however, that there are several others available to you such as vi and emacs, and we encourage you to try several editors to find which one you are most comfortable with.
To create a new file or edit an existing one, simply invoke the editor by typing the pico command, followed by the name of the file, as shown in the following syntax:
pico filename
If no such filename currently exists, pico will create a new file using the filename you specify.
Example: Create a new file called "hello" by typing the following at the command prompt:
> pico hello
The pico editor opens the empty hello file, and your screen will look something like the screen below:
Because the file is empty, the editing screen will look blank. While in the editor, type some text, for example:
Testing 123
Now hit [ENTER] twice. UNIX tends to behave better when it sees a few blank lines (also called "hard returns") at the end of a text file, so it’s good to get in the habit early.
To save the new contents of this file, press Ctrl+X. Pico will ask if you would like to save the contents of the file. Press Y to do so. Finally, pico will ask you what to name the saved file (File Name to write). By default, pico suggests you keep the same filename, so simply press [ENTER] to accept.
NOTE: Commands that are issued within the pico editor are not case sensitive.
While using pico, there are several key combinations that will help you view or edit a file. Some useful key combinations, along with their definitions, are:
Ctrl+G Take the pico tutorial
Ctrl+V View next page
Ctrl+Y View previous page
Ctrl+A Go to the beginning of a line
Ctrl+E Go to the end of a line
Ctrl+C Display the line number you are currently on
Ctrl+W Search for a word or phrase
Ctrl+O Save (write-out) the file
Ctrl+X Exit the pico editor
You can learn more about pico by pressing Ctrl+G from within the pico program itself, or by typing the following from the command prompt:
> man pico