CMMG Biocomputing Facility
Online Help Guides

Editing Text in UNIX

[ Genetics Computer | GCG | Windows 95 | Online Guides | CMMG Home ]


EDITING TEXT ON THE GENETICS UNIX COMPUTER

Editing text is a skill everyone needs to master.  There are 3 text
editors available on the Genetics computer:
 
PICO, VI, and TEXTEDIT.  

You may use them to edit any text file in your home directory.  These may
include configuration files such as .cshrc and .login, or, for example,
DNA or protein sequence files that you wish to export for analysis.  For
large or complex files, you may find it easier to create and edit the text
with a text editor or word processor (save as text only) on your PC and
then send the file to Genetics via ftp (ascii mode).

===========================================================================

The PICO Text Editor

PICO is an easy to use full screen text editor available on Genetics.  To edit
with pico, from the genetics% prompt type: 

pico filename

Help and commands are listed at the bottom of the screen.  New text is
inserted automatically from the cursor position, and is automatically
wrapped around the end of the line.  Use the arrow and backspace keys to
make changes. Functions include a simple spell-checker, importation of
text from other already existing files, text marking (cut & paste), and a
directory browser. 

The pine email system uses pico as the text editor for editing messages. 
The HYBROW directory browser also uses pico as its standard text editor. 

To use pico as a file viewer (readonly mode), type pico -v filename.  To
disable word wrap, so that you can edit long text lines, type 
pico -w filename. 

Though not as powerful as vi, pico is so much easier to use that you may
want to use it most of the time.  Read the help pages from within pico to
learn about the basic features of pico, or type man pico from the genetics%
prompt.  The pico HELP text is listed below. 

        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.
 
        Pine and Pico are trademarks of the University of Washington.
        No commercial use of these trademarks may be made without prior
        written permission of the University of Washington.

===========================================================================

The VI Text Editor:

DESCRIPTION:

VI (visual) is a display oriented full screen text editor.  VI is the
standard UNIX text editor, so if you learn VI, you can edit text on any
UNIX computer.  It has powerful features, but most people find it more
difficult to use than PICO. 

There are two "Modes" in VI, Command Mode and Insert Mode.  When VI first
starts, it is in Command Mode.  In Command Mode, you can move around in
the text with the arrow keys, delete text, insert files, display line
numbers, and so on.  In Insert Mode, you can type new text.  To start
Insert Mode, press the I key.  To return to Command Mode, press the 
Esc key.

View is a variation that runs vi in the readonly mode.  With view, you can
browse through files interactively without making any changes.

Vedit runs vi in the beginners mode, which is easier to use for people
just learning to use vi.  It sets the showmode flag to on, so that you
know whether you are in the command mode (moving around within the text,
deleting text) or in the insert mode (inserting or appending text).

STARTING vi:

To edit a file, type: vi filename
   or                 vedit filename

To view a file, type: view filename

"filename" is the name of the file, which may include a full path.  It may
be an existing file or a new file that you wish to create. 

COMMAND SUMMARY:

Following is a brief list of simple vi commands.

Cursor Movement:

k or up arrow           move up one line
j or down arrow         move down one line
h or left arrow         move left one character
l or right arrow        move right one character
Spacebar                move right one character
Enter                   move to the beginning of the next line
w                       move to the beginning of the next word
e                       move to the end of the next word
b                       move to the beginning of the previous word

$                       move to the end of the current line
0 (zero)                move to the beginning of the current line
G                       move to the last line of the file
1G                      move to the first line of the file
:#                      move to line number #

^f (Ctrl-f)             move one page forward
^b (Ctrl-b)             move one page back
^d (Ctrl-d)             scroll down
^u (Ctrl-u)             scroll up

Adding text:

i                       insert text before cursor position
a                       append text after cursor postion
o                       open line below current line, insert mode on
O                       open line above current line, insert mode on
Backspace		move left one character, to correct typos

Deleting text:

x                       delete current character
dd                      delete current line
d			delete current and next line
d#			delete current line and # additional lines
dw                      delete word
D                       delete to end of current line
:#d                     delete line number #
:#,@d                   delete line numbers # through @

Moving and copying text:

yy			yank current line (copy to temporary buffer)
:y#			yank # of lines, starting at current line
p			put yanked line(s) below current line
P			put yanked line(s) above current line
:#,@m%			move line numbers # - @, place below line number %
:#,@t%			copy line numbers # - @, place below line number %

Searching:

/aaaa			search forward for pattern aaaa
?aaaa			search backward for pattern aaaa
n			repeat last search command
:s/aaaa/bbb/		substitute pattern bbb for pattern aaaa in current line

Miscellaneous:

Esc                     exit insert mode; switch to command mode
u                       undo last change
.			repeat last editing command
:w                      save current version of file
:w yyyy                 save current version of file, named yyyy
:r yyyy                 read in file yyyy, insert below current line        
ZZ                      save file and exit vi
:q                      quit vi
:q!                     quit vi without saving changes
^g (ctrl-g)		show current line number
:set number             turn on line numbering
:set nonumber           turn off line numbering
:set showmode           turn on showmode (automatic with vedit)
:set noshowmode         turn off showmode

HELPFUL HINTS for VI:

To insert text, press i (insert), then type your text.  Use the backspace
key to go back and then type over any mistakes.  Press Enter at the end
of each line.  When you are finished, press Esc (escape) to return to
command mode.  You may then move around in the text to make any
corrections that may be necessary, such as deleting errors, inserting or
appending more text, or inserting text from another file. 

Use :r to insert text from another already existing file into the current
file. 

Do not use the arrow keys while you are in the insert mode, or strange
things will happen. 

Use :q! to really quit a file without saving the changes, for example if
you made the changes by mistake. 

ZZ will save the file under its current name and then quit vi.

Most commands are executed in the command mode.  If you type ZZ while
still in the insert mode, it will insert the letters ZZ.  Press escape to
return to command mode, move the cursor over the Z's, and press x to
delete each of them.  Then type ZZ to save and exit. 

=============================================================================

TEXTEDIT, The X Windows Text Editor

You can use the X Windows text editor either from within the X Windows
File Manager, or as a stand alone program.  To use it from the File
Manager, just double click on any text file to open it in Textedit.  To
start it alone, type textedit from the genetics% prompt.


[ Genetics Computer | GCG | Windows 95 | Online Guides | CMMG Home ]


Send comments to: dwomble@genetics.wayne.edu

Copyright © 2001, David D. Womble.