Unix: Editing files
You are often required to edit text files when working with your shell account.
For example, to configure where your mail is forwarded to you need to edit the
file .forward in your home directory. To do this, you will need to use
a text editor. There are many text editors available, and most of them are
utterly cryptic and take a lifetime to learn. This page gives a quick
introduction to Pico, an editor that takes minutes to master.
Using Pico
Editing files with Pico is as simple as typing:
pico filename
If you have ever used the mail program Pine, or indeed have ever used a simple text editor you should be pretty comfortable with Pico. You move around using the arrow keys, delete stuff using backspace and insert stuff by typing.
When you are finished, press Control-X, and you will be
asked whether you want to save the changes. Press Y to save your
changes, N to discard them and Control-C to go back to
editing the file. At any time you can press Control-O to save any
changes and carry on editing.
To delete a line of text, press Control-K. To paste the deleted text
at the current cursor position, press Control-U. If you press
Control-K to delete more than one line, all the lines deleted will be
pasted.
By default, Pico will wrap words at the end of the line. This is works well,
until you go an edit some text in the middle of a paragraph. To re-justify a
paragraph, place the cursor anywhere in the paragraph and press
Control-J. A paragraph is defined as the text between two blank lines.
Some files require lines that are longer than the width of your terminal and
must not be wrapped. When editing such a file it is best to give Pico the
-w option:
pico -w filename
This stops Pico from doing any word-wrapping at the end of lines.
Other editors
Whilst Pico is certainly very easy to learn, it is somewhat limited in functionality. If you are going to be doing a lot of editing on Unix, you would do well to learn one of the more fully featured text editors, such as vi, vim, joe or emacs. Unfortunately, the question of "which text editor is best" is an ongoing, vociferous and uninteresting debate. We will not expose you to our opinions unnecessarily.
Copyright © 2000-2007 Mythic Beasts Ltd. All Rights Reserved.

