Copying and Editing a Class Resource File
Lab 1 Supplement
CSC220, Spring 2005

Throughout the semester you will be asked to retreive sample files and study and/or modify them. This exercise gives you practice.

You will learn two skills:

    Use emacs to edit documents such as Java files.
  1. Copy course resources.

copy files

  1. get to a Unix xterminal window on any of the three platforms. (see Lab 1 for instructions!)

  2.  

     
     
     

    The Unix prompt will designate which machine you are on:

    bigbird[1]%

    designates machine "bigbird" waiting for the first command from you.
  3. You will copy files from a course directory called "psjava" (Problem Solving with Java). Unix has short text-based commands. The "cp" command requires two parameters, a source and a destination. You are to copy the file ~mmmartin/survey.txt to your directory. Your current directory is designated by a period. Look carefully at the command below. There is no space between the "m" and "~" and there's a space between the last "t" and the "."

  4.  

     
     
     

    bigbird[2]%cp ~mmmartin/survey.txt .

  5. Look to see if you have successfully copied the survey. The "ls" command lists the files in your directory (folder). When you give it the "switch" -l it gives details. Try both. Here is the ls -l version:
  6.  
     

    bigbird[3]% ls -l
    total 10
    drwx------ 2 cstest students 512 May 26 17:23 mail
    -rwx------ 1 cstest students 3662 Sep 3 12:04 survey.txt

emacs

In order to create programs you will have to learn how to use a text editor. A text editor is not exactly the same as a word processor. The former allows you to edit "text" including program code. A word processor is a text editor whose main features allow you to compose, format and edit a natural language such as English. Most text editors have limited word processing capability. Some text editors are also word processors, and some word processors can also be used to develop code. Most word processor imbedded control characters, a "secret" code that specifies how to format text, for example to underline a word. Take care if you use a word processor such as MS Word to create Java code, because Word may insert hidden characters that will confound the Java compiler.

For this course it's strongly recommended that you develop proficiency using a text editor called "emacs, because it is the editor of choice for your instructor. Later in the semester when she attempts to help you debug a program she will expect to be able to work with you in emacs. Another editor similar to emacs is xemacs. It provides a graphical user interface, but sometimes it doesn't always do what you expect. Yet another editor is vi. It has a strong following among Unix users, but your instructor prefers emacs and in fact, has never learned vi. Other professors may encourage you to learn vi down the road. Finally there is "peco." Do not get in the habit of using peco for your programming assignments, because it is a very restrictive, limiting environment that will frustrate you in the long run. Although emacs, xemacs, vi have the largest "learning investment" in the long run, developing mastery of these editors will enhance your ability to program effectively on the suns.

  1. Get "into" emacs and "do" the tutorial:
  2. bigbird%[1] emacs

    will create an emacs window and display a set of commands you can execute. Read the instructions about the "C" and "M" keys carefully! Note that if you are using a Mac keyboard do NOT use the "alt" key, use the "esc" key. Somewhere in the display it tells you how to reach the tutorial. If you can't get to the tutorial ASK!

    leave emacs. If you didn't learn it in the tutorial: C-X C-C quits.

  3. Now edit the survey using emacs:
  4. bigbird[1]% emacs survey.txt

    opens an emacs environment and loads the file specified.

  5. Save the modified survey. If you make a mess of the survey you can simply copy another one. If you didn't learn how to save in the tutorial, C-X C-S saves.
  6. Upload your modified survey to the CSC220 dropbox of your instructor.