Академический Документы
Профессиональный Документы
Культура Документы
You will benefit greatly if you make frequent use of the following features, which are beneficial for
all applications but especially when you are writing C/C++/etc. programs:
VERY IMPORTANT: search/replace
VERY IMPORTANT: subwindows
VERY IMPORTANT: block operations
VERY IMPORTANT: undo/redo operations
VERY IMPORTANT: auto-indent mode
VERY IMPORTANT: keyboard macros
VERY IMPORTANT: misc.---save-no-exit, go-to-line, go-to-last-position, parenthesis-matching, etc.
Start Here:
Important notation: Throughout the joe documentation, the carat symbol, i.e. ^, means the Control key. Also, note that within joe
commands, capitalization does not matter; for instance, when we say that ^U means to scroll up one page, it is the same as ^u.
To edit a file using joe, say the file x, type
joe x
However, I strongly recommend that you use the -help command line option:
joe -help x
Here you are asking joe to edit an existing file named "tonguetwister" or create a new one if one doesn't exist. (I will assume one
doesn't already exist.) Note that the option "-help" is nice to have, since it automatically sets up an online help subwindow, but is not
required.
Then a blank editing buffer will appear (since the file is new), with the help subwindow at the top of the screen:
Help Screen
CURSOR
^B left ^F right
^P up ^N down
^Z previous word
^X next word
SEARCH
GO TO
^U prev. screen
^V next screen
^A beg. of line
^E end of line
^KU top of file
http://heather.cs.ucdavis.edu/~matloff/Joe/NotesJoe.NM.html
BLOCK
^KB begin
^KK end
^KM move
^KC copy
^KW file
DELETE
^D char.
^Y line
^W >word
^O word<
^J >line
MISC
^KJ reformat
^T options
^R refresh
^@ insert
SPELL
EXIT
^KX save
^C abort
^KZ shell
FILE
^KE edit
1/6
14/12/2015
tonguetwister
Row 1
Col 1
^KR insert
^KD save
New File
Now save the file and leave joe, by typing ^KX where x is for "exit" (if we wanted to exit without saving the file we would type ^C).
Now, suppose we suddenly remember that we wanted to write "a seashore" instead of "the seashore". We invoke joe again:
joe -help tonguetwister
This time we will see our old work there in the file:
Help Screen
CURSOR
^B left ^F right
^P up ^N down
^Z previous word
^X next word
SEARCH
^KF find text
^L find next
GO TO
^U prev. screen
^V next screen
^A beg. of line
^E end of line
^KU top of file
^KV end of file
^KL to line No.
IW
BLOCK
^KB begin
^KK end
^KM move
^KC copy
^KW file
^KY delete
^K/ filter
DELETE
^D char.
^Y line
^W >word
^O word<
^J >line
^_ undo
^^ redo
Row 1
Col 1
tonguetwister
MISC
^KJ reformat
^T options
^R refresh
^@ insert
SPELL
^[N word
^[L file
EXIT
^KX save
^C abort
^KZ shell
FILE
^KE edit
^KR insert
^KD save
Now simply use the arrow keys to move the cursor to the point just before "the". We then remove the word, one letter at a time (actually
there is a shortcut we could use to remove the whole word at once), using ^D Then save/exit with ^KX.
advanced features in joe or any other sophisticated editor (many of the features you will see here are also in emacs, vim,
elvis, etc.) is to save you time! For that reason, take a little bit of time to learn them NOW; that very small investment in time now
will save you lots of time later, allowing you to better concentrate on the task at hand---writing programs.
Most of the advanced features are obvious just from looking at the on-line help window. For instance, you can delete an entire line by
typing ^Y. (This is far better than laboriously typing ^D to remove the line one character at a time.)
To invoke the on-line help feature (if it is not already invoked), type ^KH where the h is for "help". A help window will then appear at
the top of the screen. To scroll through the help window, type ^[. to go forward, ^[, to go back. You may exit help by typing ^KH again,
but on the other hand if you are a beginner you might as well just leave the help window there throughout your editing session.
Again, many of the advanced features will be clear just from the help window. But there are a few features which it is
extremely important for you to pay special attention to. Click here to learn them.
Search/replace:
Suppose you are editing a program source file, and you have a variable named Sum. You know there is some line in the file
containing Sum which you wish to change. One way to look for it would be to scroll through the file, using ^U to scroll up or ^V to scroll
down, and scan visually.
But a much better way would be to use joe's search facility. Just type ^KF f, where f is for "find". It will prompt you for the string which
http://heather.cs.ucdavis.edu/~matloff/Joe/NotesJoe.NM.html
2/6
14/12/2015
you wish to find, in this case "Sum". (You will then be prompted for options on the type of search, but for this simple case just hit the
Return key.) This will bring the cursor to the first instance of Sum after the original position of the cursor. After that, you can travel
through all instances of Sum by continuing to hit ^L.
Suppose you wish to change all instances of Sum by Total. Then you could proceed as above, but type r (for "replace") when
prompted for an option in your search. This would change the first instance of Sum by Total; ^L would take you to the next instance,
and if you type r then (for the "rest") the replacment will be made by all of the rest of the instances of Sum.
Subwindows:
Subwindows are extremely useful. They will make your program writing and debugging much easier. Use them often!
In editing program source files, a common usage of subwindows is to have one subwindow showing the declaration of the function
and the other one show a call to the function. That way one can easily check whether the parameters are correctly specified in the call.
Here is an example:
Suppose I am editing a C-language source file p.c, and that I am interested in the function IsComposite(). I first type
joe p.c
and then use the joe Find command ^KF to get to the declaration of the function:
I A p.c
Row 76
Col 8
I now type ^KO to split the current window into two subwindows:
I A p.c
Row 76
Col 8
if (N % Block > 0) {
if (Me == 0) printf("N must be divisible by Block\n");
exit(1);
}
/* OK, get started; first record current time in T1 */
if (Me == 0) T1 = MPI_Wtime();
}
int IsComposite(K) /* returns 1 if K is found to be composite */
I A p.c
Row 76
Col 8
if (N % Block > 0) {
if (Me == 0) printf("N must be divisible by Block\n");
exit(1);
}
/* OK, get started; first record current time in T1 */
if (Me == 0) T1 = MPI_Wtime();
}
int IsComposite(K) /* returns 1 if K is found to be composite */
At the start, the two subwindows are pointing to identical spots in the file. But I can move throughout the file within the two subwindows,
http://heather.cs.ucdavis.edu/~matloff/Joe/NotesJoe.NM.html
3/6
14/12/2015
indpendently of each other. For example, in the lower subwindow (which is the one in which the cursor is currently), I will use the joe
Find command ^KF to go to the next instance of the string IsComposite, which will be the place at which the function is called:
I A p.c
Row 76
Col 8
if (N % Block > 0) {
if (Me == 0) printf("N must be divisible by Block\n");
exit(1);
}
/* OK, get started; first record current time in T1 */
if (Me == 0) T1 = MPI_Wtime();
}
int IsComposite(K) /* returns 1 if K is found to be composite */
I A p.c
Since I wish to see the function declaration in the upper subwindow, I first type ^KN (n for "next subwindow") to get the cursor into that
subwindow, and then use the down-arrow key a few times to scroll the display in that subwindow:
I A p.c
Row 72
Col 1
if (Me == 0) T1 = MPI_Wtime();
}
int IsComposite(K) /* returns 1 if K is found to be composite */
int K;
{ int J;
for (J = 2; J*J <= K; J++) {
/* if J is known to be composite, don't bother dividing by it */
I A p.c
If I want to go back to using just one window, I can type ^C in the current subwindow.
Undo/redo:
Oops! We all make mistakes, but sophisticated editors like joe allow you to undo them. Just type ^_ (hold down the Control, Shift and keys) to undo your last change within this editing session. And if you want to undo the next-to-the-last change, type ^_ again, and so
on. And if you decide you undid too many changes, you can redo them by typing ^^ (hold down the Control, Shift and ^ keys), where
again you can do this multiple times for multiple changes.
Auto-indent mode:
As you know, good programming style includes indenting lines to highlight loops, if-then-else constructs, and so on. But don't hold
down that space bar to indent so many spaces! Instead, use the auto-indent mode. In this mode, whenever you hit Return to start
typing on the next line, joe automatically will indent to the same amount as the previous line.
In general, joe will infer from the type of the file being edited (such as .c files for C) that it is a program source file and thus joe will
begin in autoindent mode. You can leave/enter this mode by typing ^TL.
http://heather.cs.ucdavis.edu/~matloff/Joe/NotesJoe.NM.html
4/6
14/12/2015
Keyboard macros
Suppose you are now typing some program source code into a file, and you have a long variable name, say OverallSalesTotal.
Instead of typing that by hand every time, you can save yourself typing as follows: Hit ^K[ and then when prompted, choose a number
from 0 to 9 to name this macro; say you choose 6. Then type "OverallSalesTotal" (without the quote marks) followed by ^K] From that
point on, whenever you want to type OverallSalesTotal you need only type ^K6 and joe will type OverallSalesTotal for you! This not only
saves time, but also again allows you to concentrate better on your programming, instead of being distracted.
Block operations
Often one wishes to either move or copy "cut and paste") a whole block of text within a file to another point in the file. Here is how to do
this in joe:
First one highlights the block, by moving the cursor to the start of the block and typing ^KB then moving to the end of the block and
typing ^KK.
Then to either move or copy the block, move the cursor to the destination, and then type either ^KM (to move) or ^KC (to copy). On the
other hand, if you simply wish to delete the block, type ^KY.
would bring up joe with two subwindows, each containing one file, but the second one would carry the notation "(Read only)" and would
not allow you to change the file.
http://heather.cs.ucdavis.edu/~matloff/Joe/NotesJoe.NM.html
5/6
14/12/2015
Math calculator:
To use joe's math service, type ^[M upon which an = sign appears at the bottom of the screen. You can then enter a numeric
expression, e.g.
=(4.2+3*5.9)/6.5
http://heather.cs.ucdavis.edu/~matloff/Joe/NotesJoe.NM.html
6/6