- There is a text editor vi in AFS space that you can use to create or fix files.
It is a modal editor meaning that different things happen when you type, depending on
which mode you are in.
There are two modes, Command mode and Typing mode.
- Use vi filename to open a file.
It opens in Command mode.
- Use vi (without a filename to get a copy of the Vim manual - Vim is vi).
- Use arrows to go left and right, up and down in either mode.
- Use o in Command mode to go to Typing mode and open a new line.
- Use "ESC" to go back to Command mode from Typing mode.
- Use :w to save your file from the Command mode (remain in Command mode).
- Use :q from the Command mode to quit
(:wq saves and then quits with one command).
- Use x in the Command mode to delete (remain in Command mode).
- Use i in the Command mode to go into Typing mode.
- Similar to x, there is also dd for deleting an entire line in Command mode
(remain in Command mode); 5 dd deletes the next 5 lines.
- Similar to i, there a for append (change to Typing mode).
- If the cursor is over a brace, bracket or parenthesis in Command mode, the % key will jump it to the
matching brace, bracket or parenthesis
(the utility of this will become apparent as the course develops).
This short introduction will get you started on the vi editor.
Of course there are a lot of powerful commands in this editor
and it would take a long time to learn them all.
Fortunately you can get by in this course with
just the above. For those who wish additional information, here
is a link.
Unix command
ls --- list files and directories
cd --- cd dirname -- change directory
mv --- mv filename1 filename2 -- change file name or move a file into a different directory
rm --- rm filename -- delete a file
pwd --- show path of current directory
cp --- cp filename1 filename2 -- copies a file
mkdir --- mkdir dirname -- make a new directory
more --- more filename -- shows the first part of a file, just as much as will fit on one screen. Just hit the space bar to see more or q to quit.
- Compiling:
Use the g++ compiler on the UNIX machines.
-
Create your program using a text editor on your computer system.
The program should be saved as a text file with an extension of .cpp.
Remember that any unix operating system is case-sensitive.
-
Now you are ready to compile your program, file.cpp, into an
executable file. At the prompt you give the command (assuming this
is the only file that you want to compile):
This compiles your source file,
file.cpp, into an executable program.
On unix-based systems, the executable program is automatically
named a.out.
If any errors occur in the program the g++ compiler will report these
errors. You must correct any errors and compile the program
again.
- To execute the program itself, the command is: This should execute your program on your unix system.
- If you have multiple files for a single program,
you can use
g++ file1.cpp file2.cpp file3.cpp file4.cpp
This will generate the executable file a.out.
(Later in the semester we will have such assignments.)
Click here to return to home page.