Recall: we're using the term computerese to mean all the
non-programming related skills you need on your computer,
like making and changing directories, to be successful
in getting your programs done.
Up to this point you are proficient in:
- Editing: typing in a program, moving the cursor around in
pico.
- Compiling and executing using
javac
and
java
respectively.
- Doing other things like making a directory,
moving between directories, and so on.
All of these were described in
Module 0 of Unit-0.
Our goal in this module is to go a little further, and mention
some more useful computerese.
Ultimately, the goal is to become more productive.
More pico commands
As our programs start getting larger, it will be slow to
move around text in
pico
using just the arrows. Here are some commands worth trying
for longer programs
- Instead of slowing moving across a line character by character:
- Move a word at a time using
ctrl-space
- Move to the end of a line using
ctrl-e
- Move to the beginning of a line using
ctrl-a
- Use
ctrl-v
and
ctrl-y
to move up and down a whole page at a time.
- Use
ctrl-w
to find something in the file. This is often really useful
when you've returned from a break and quickly need to
find the method you've been working on.
- Sometimes, you need to move a block of code from
one place in the file to another. To do that,
delete it from the first place using successive
ctrl-k
- You can save a file without exiting from
pico
using
ctrl-o.
We'll see next why this is useful.
Use two windows
Thus far, in the edit-compile-execute process, we've
gotten out of the editor and then compiled.
The problem is, if there's a compiler or execution error,
we get back into the editor and repeat.
To make the repeated process more efficient:
- Open two terminal windows. The second one can be
opened from the File menu of the first. Try it.
- Once you have the second one opened, go to the same
directory.
Now you can edit in one window (keeping
pico.
open) and compile/execute in the other.
Wildcards
Go back to your Module-4 directory where you wrote all your
exercise code.
In that directory, type
ls
to get a list of files.
Because you compiled many files, you'll see both
.java
and
.class
files.
Now type
ls *.java
at the command line.
You will see only the java files.
The "*" is called a wildcard. The "*" says "any characters"
can be substituted here.
You can see this work differently by typing
ls *.j*
which will match any file name that fits the pattern:
- Any string of characters before the dot.
- A
j
after the dot.
- Any string of characters that follow the
j.
Why is this useful? If you want to move all your java
files, or delete all your
.class
files, you can use wildcards.