Other important points:
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 xso that the help window is automatically brought up.
Now, before going any further, go through our
First, type
joe -help tonguetwisterHere 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 turn off with ^KH more help with ESC . (^[.) CURSOR GO TO BLOCK DELETE MISC EXIT ^B left ^F right ^U prev. screen ^KB begin ^D char. ^KJ reformat ^KX save ^P up ^N down ^V next screen ^KK end ^Y line ^T options ^C abort ^Z previous word ^A beg. of line ^KM move ^W >word ^R refresh ^KZ shell ^X next word ^E end of line ^KC copy ^O word< ^@ insert FILE SEARCH ^KU top of file ^KW file ^J >line SPELL ^KE edit ^KF find text ^KV end of file ^KY delete ^_ undo ^[N word ^KR insert ^L find next ^KL to line No. ^K/ filter ^^ redo ^[L file ^KD save IW tonguetwister Row 1 Col 1 9:48 Ctrl-K H for help New File ** Joe's Own Editor v2.8 ** Copyright (C) 1995 Joseph H. Allen **
Now put something into the file, by typing
She sells seashells by the seashore.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 tonguetwisterThis time we will see our old work there in the file:
Help Screen turn off with ^KH more help with ESC . (^[.) CURSOR GO TO BLOCK DELETE MISC EXIT ^B left ^F right ^U prev. screen ^KB begin ^D char. ^KJ reformat ^KX save ^P up ^N down ^V next screen ^KK end ^Y line ^T options ^C abort ^Z previous word ^A beg. of line ^KM move ^W >word ^R refresh ^KZ shell ^X next word ^E end of line ^KC copy ^O word< ^@ insert FILE SEARCH ^KU top of file ^KW file ^J >line SPELL ^KE edit ^KF find text ^KV end of file ^KY delete ^_ undo ^[N word ^KR insert ^L find next ^KL to line No. ^K/ filter ^^ redo ^[L file ^KD save IW tonguetwister Row 1 Col 1 2:45 Ctrl-K H for help She sells seashells by the seashore. ** Joe's Own Editor v2.8 ** Copyright (C) 1995 Joseph H. Allen **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.
Using what you have learned in the 2-minute trial run, you now have enough skill to use joe for your own editing activities at a rudimentary level. But it is very imoprtant to learn some of joe's more advanced features. Always keep in mind that the purpose of 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.
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 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 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.cand then use the joe Find command ^KF to get to the declaration of the function:
I A p.c Row 76 Col 8 12:31 Ctrl-K H for help redundant versions of this message) */ 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 */ int K; { int J; for (J = 2; J*J <= K; J++) { /* if J is known to be composite, don't bother dividing by it */ if (!Composite[J]) if (K % J == 0) return 1; } return 0; }
I now type ^KO to split the current window into two subwindows:
I A p.c Row 76 Col 8 12:35 Ctrl-K H for help 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 12:35 Ctrl-K H for help 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, 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 12:41 Ctrl-K H for help 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 127 Col 20 12:41 Ctrl-K H for help Last = First + Part - 1; NIters = N / Block; for (Iter = 0; Iter < NIters; Iter++) { NNew = 0; for (I = First; I <= Last; I++) if (IsComposite(I)) { New[++NNew] = I; Composite[I] = 1; MyComposites++; } New[0] = NNew;
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 12:45 Ctrl-K H for help 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 Row 127 Col 20 12:45 Ctrl-K H for help Last = First + Part - 1; NIters = N / Block; for (Iter = 0; Iter < NIters; Iter++) { NNew = 0; for (I = First; I <= Last; I++) if (IsComposite(I)) { New[++NNew] = I; Composite[I] = 1; MyComposites++; } New[0] = NNew;
If I want to go back to using just one window, I can type ^C in the current subwindow.
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.
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.
After you compile, you may find some compilation errors, flagged by line numbers. Joe's command ^KL will take you to the specified line. (Joe also has its own commands for compiling and going to lines with compilation errors. However, the documentation on this does not seem to exist.)
Another useful command for moving the cursor is ^K- which moves you to the previous place where you had had the cursor. So if you are looking at one part of your code but wish to briefly check something in another part of the code, you can go to the other part and then easily return to the original place by using this command.
Actually, this ^K-command returns you to the last place where you made a change to the file. If you keep hitting ^K- you will step through the sites of all your previous changes; conversely, if you keep hitting ^K= then you will move forward through this list.
Also very useful when editing program files is parenthesis matching. Suppose you have a heavily-nested parenthesized expression. If the cursor is currently pointed to one parenthesis, hitting ^G will move the cursor to the parenthesis' mate, if it exists. This way you can check that your parenthesizing is set up correctly.
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.
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.
It makes good sense to use the same editor for all your work. Thus it would be nice to have joe as your default editor in your e-mail utility, say pine. That means that whenever your compose a new e-mail message or reply to one you receive, your e-mail utility will automatically invoke joe for your editing pleasure. When you are done editing your message, you simply exit joe as usual using ^KX, and then your e-mail utility will take over again and ask if you want to go ahead to send the message, as usual.
I personally use the mutt e-mail utility, and I strongly recommend it. But most of you use pine, so here is how to make joe your default editor in pine:
When your first invoke pine, first choose S (Setup), then C (configure. Scroll through the choices there until you get to enable-alternate-editor-implicitly; there just type x and an X will appear in the box. (If you check the wrong box by mistake, just type x again to make it disapear.)
Then continue to scroll though the choices until you come to "editor". At that point choose C (Change Val) and type joe. Then choose E (Exit Config) and answer y when asked whether to Commit.
From this point on, joe will automatically pop up whenever you compose a new message or reply to an existing one. (If you later wish to undo this and revert to pine's internal editor, just go through the above configuration process and change at least one of the two items we changed above.) As mentioned earlier, when you are done composing your message, simply exit joe with ^KX and then send the message as usual.
You may wish to use joe to only view a file, not change it. Although you could just invoke joe as usual, this would be dangerous, since you might accidentally change the file. To avoid this, use the -rdonly option before the file name on the command line.
For example,
joe x -rdonly ywould 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.
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
and joe will give you the answer.