The purpose of this lab is to teach you some basic emacs commands.
Assuming that you have started your emacs editing session, try the following.
Start typing whatever you want to type in that buffer of your
current emacs session. In fact, type about 10 lines of text so
that we can start editing it.
Assuming the cursor is at the end of the buffer (buffer is what
you see in the emacs window as you start a session), let's move
your cursor around - the location of the cursor is where your
typing point is in your buffer.
c-f [ Try control-f meaning holding down the control key and f
simultaneously - this will move your cursor one character
'f'orward. Uppercase F or lowercase f will do the same.
The same is the case with other letters below. ]
c-b [ One character 'b'ackward ]
c-p [ To the 'p'revious line ]
c-n [ To the 'n'ext line ]
c-a [ To the beginning of the current line ]
c-e [ To the 'e'nd of the current line ]
c-x c-s [ Save the changes made so far - try this every so often
to save incrementally so that you don't lose any editing you
have done so far ]
c-x c-w [ To save the current buffer into a new file. When you
try this command, it will ask for a new file name. This is a
way to create a new file. You can copy a file this way too. ]
c-x c-c [ Exit emacs permanently ]
c-z [ Suspend emacs and return to the Unix prompt if you are using
Unix. Ignore this command if you are using Windows. To
continue the editing session with the suspended emacs, try
the unix command 'fg' meaning foreground ]
c-g [ Abort partially typed or executing command - you will find
this quite useful. If you are in the middle of some command
execution and if you are not sure where you are, try this
to abort the current command. Then, you can start it
again. ]
c-s [ Incremental search. After you hit c-s type in the text that
you want to search forward in the buffer. Try this command,
i.e., c-s repeatedly searching a text that occurs multiple
times in the buffer. In fact, as you start the command,
emacs will highlight all the occurrences of the text that
you are currenting searching in the current window. ]
c-r [ Incremental search backward. Similar to c-s except you are
searching the text backward. Again try repeatedly. ]
m-< [ Go to the beginning of the buffer. m- means the Esc key.
This is useful when you are editing a large file. ]
m-> [ Go to the end of the buffer. ]
c-v [ Go to the next page ]
m-v [ Go to the previous page ]
backspace [ To delete the character before the cursor ]
c-d [ To delete the character on the cursor ]
c-k [ To kill/delete the rest of the current line. So, go to the
beginning of a line and try c-k to delete the current line.
If you want to delete multiple lines, use c-k repeatedly.
All the lines that you killed will be temporarily saved in
the 'kill buffer' and you can undo the 'killing' by
'yanking' it back from the kill buffer. To yank it back see
the next command: c-y. ]
c-y [ To retrieve the content of the 'kill buffer'. See the c-k
command above. In fact, if you want to move a series of
lines to a different location of your buffer, try c-k to
kill the text that you want to move, relocate the cursor to
the target location, and try c-y. If you want to copy, you
can try a similar thing except try c-y twice after you kill
them: once in the current location and once more in the
target location. ]
c-x 2 [ To split the buffer into two, above and below ]
c-x 3 [ To split the buffer into two, side by side ]
c-x o [ To move the cursor to the other buffer ]
c-x 1 [ To close all the other split windows except the one where
the cursor is located ]
c-x X-f [ To bring another file into the editing session. So, you
can have as many files open into your editing session as
possible using this command. In fact, bring in several for
this exercise.
As you deal with existing file names, you will find
automatic file name completion feature useful. Emacs knows
how to complete the file name so use the space bar to try to
complete the file name whenever appropriate. ]
c-x c-b [ To see all the buffers in the session in the other half
of the window. At this point, if you want to get to anohter
buffer, use 'c-x o' to get to the buffer with the list and
move the cursor to the buffer you want and simply type 'f'
without the quotes on the line containing the buffer's
name. ]
c-x b [ To move to another buffer without seeing the list of the
buffers in the ohter half of the window. This is useful if
you already know the name of the buffer. Or if you want to
move between two buffers since the other one will be the
default one you can just accept. ]
More... There are many many more commands you will find useful.
See the manual or at least the Quick Reference card. Or, you can
always google to find a more complete user's manual.