<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%====================================================================
\section*{Survival Emacs}
%====================================================================

There are a ton of resources on the web to teach yourself emacs. And
you will need to use a bit of your web/search savvy at some point to
learn more.  This help topic covers my own "survival emacs" tips I
find myself repeating many times to new users. So before you're
confronted with the reality that you're mostly on your own to teach 
yourself, here's a few things to get you going.

%====================================================================
\subsection*{Opening and closing emacs}

If I were opening a text editor for the first time, the first thing I'd 
want to do is open a file, make some changes and play around, and exit
without saving those changes. So that's the first thing we'll cover 
here:

\vspace{0.1in}
\begin{packed_itemize}[0]
\item To open emacs, just type \var{emacs testfile.txt} on the command line.
\item To close emacs, type \var{C-x, C-c}, which is shorthand for typing
the \var{Control} and \var{x} key, followed by the \var{Control}
and \var{c} key.
\end{packed_itemize}
\vspace{0.1in}

\noindent
If you want to type in some changes in between opening and closing, 
just type, and move around with the arrow keys. If you want to exit 
without saving the changes, just type \var{C-x, C-c} as before, and 
when you're prompted with:

\vspace{0.1in}
\noindent
\var{Save /home/you/testfile.txt? (y, n, !, ., q, C-r, d, C-h)}
\vspace{0.1in}

\noindent 
type \var{'n'}, you don't want to save changes, and type \var{yes} when
you are subsequently questioned if you really want to exit without saving
changes.

%====================================================================
\subsection*{Saving Changes}

Now that you know how to open an edit session and exit, you may want to
actually save some changes! At any time just type \var{C-x, C-s} to 
save changes. In case you're ever wondering if there are any "pending"
changes to be saved, you can always look at the bottoms of the emacs
window for a line that looks something like:

\vspace{0.1in}
\begin{fileverb}
--:**-  testfile.tex   All L1   (Tex)-----------------------------
\end{fileverb}
\vspace{0.1in}

\noindent
If you see the asterisks on the left, then the file you are editing has
pending changes that have not yet been saved. After you save the file, 
you should see the line change to something like the below, with the 
asterisks now gone:


\vspace{0.1in}
\begin{fileverb}
--:---  testfile.tex   All L1   (Tex)-----------------------------
\end{fileverb}

%====================================================================
\subsection*{Get Out of Jail Free Card}

Here's an emacs command you should know from day one.  Now that you've
experienced emacs commands such as \var{C-x, C-s} (Save) and \var{C-x,
C-c} (Quit), you may find yourself fat-fingering something else by
mistake. Here's how to set things right:

\begin{packed_itemize}[0]
\item Type \var{C-g} at any time to quit any emacs command you may be in
the middle of, and return to the normal editing mode.
\end{packed_itemize}
\vspace{0.1in}

\noindent
For example, try typing \var{C-x, C-d} which is right between the Save and
Quit commands. You'll see the cursor moves to the buffer at the 
bottom of the emacs window with something like:

\vspace{0.1in}
\noindent
\begin{fileverb}
List directory (brief): ~/
\end{fileverb}
\vspace{0.1in}

\noindent
which is harmless enough (it just lists the contents of the directory
shown). But it's not what you wanted, and now your cursor is down at the 
bottom and emacs is apparently looking for an answer from you. Just
type \var{C-x, C-g} to get back to editing the file.


%====================================================================
\subsection*{Cut and Pasting}

Copy/Cut and paste in emacs is known as "kill" and "yank":

\begin{packed_itemize}[0]

\item \var{C-k} to "kill" everything to the right of the cursor and hold it
in an internal buffer. (Hint: type it twice to kill the line and the
line feed at the end.

\item \var{C-y} to "yank" everything previously killed and in the internal 
buffer.

\end{packed_itemize}

</pre></body></html>