-->
Previous | Table of Contents | Next |
To edit or look at a file that already exists in your current directory, enter emacs followed by the filename. For example, try this with the file you created in the previous section by entering this command:
emacs emacs-pract.1
You see the following:
Things to do today. a. Practice emacs. b. Sort sales data and print the results.
Look at the mini-buffer: It contains the name of the file youre editing.
TROUBLESHOOTING:
I typed a filename I know exists, but emacs acts as though Im creating a new file. You may have typed the name of a file incorrectly, or you may have typed one that doesnt exist in your current directory. If, for example, you type emacs pract1. and press <Return> but theres no file named pract1. in your current directory, emacs still starts, but because the named file doesnt exist, emacs acts as though you were creating a new file.I try to edit a file, but emacs displays a message about read permission being denied, and the shell prompt appears. Youve tried to edit a file you arent permitted to read. Also, you cant edit a directory-that is, if you type emacs directory_name, where directory_name is the name of a directory, emacs informs you that you opened a directory and wont let you edit it. If you try to use emacs with a binary file instead of an ASCII file, youll see a screen full of strange (control) characterssomething you cannot read and edit. emacs expects files to be stored as plain text.
When I tried to open a file in emacs, I got a message about the line being too long. Youre trying to use emacs on a data file or a binary file thats just one long string of bytes.
When I try to save a file with the <Ctrl-x><Ctrl-s> keys, the terminal hangs and doesnt respond to the keyboard. Your terminal is probably responding to the flow-control characters <Ctrl-s> and <Ctrl-q>. Press <Ctrl-q> to restart your session.
I opened a file in emacs, and some strange characters appeared on-screen. You may be using emacs with a file produced by a word processor.
In all these cases, press <Ctrl-x><Ctrl-c> to exit emacs and return to your login shell prompt. Then answer n to the prompt asking if you want to save the file. Using those keystrokes ensures that you quit emacs and make no changes to the existing file.
As already stated, to exit emacs, press <Ctrl-x><Ctrl-c>. If you havent saved any changes to the file, emacs prompts you to save the buffer. If you type y, emacs saves the file and returns you to the Linux shell. If you havent provided a filename, emacs prompts for a filename and then exits. If you respond n to the request to save the buffer, emacs prompts again to make sure that you want to exit without saving the buffer. This time you must completely type out the response to the promptyes or no. If you answer yes, emacs returns you to Linux without saving any of the modifications you made to the buffer. Also, if you have multiple buffers open, emacs prompts you for each buffer.
CAUTION:
The default installation of emacs performs periodic saves while youre editing a buffer. emacs does not, per se, make backup copies of files, although the first time you save the file, a snapshot of the file is saved in #filename#. After you press <Ctrl-x><Ctrl-s>, the original file is modified and cant be restored to its original state. Thus, you should make your own backup copies of emacs files before starting the editing session to make sure that the automatic updates dont inadvertently overwrite an important file to the point where you cant recover a previous version of the file.
CAUTION:
Answer n to the exit-without-saving prompt sparingly. When you answer n, all the changes youve made to the file since it was last saved are lost. Its better to be safe and save the file to a different filename if youre not sure about losing all your changes to the file.
Perhaps you arent quite finished with your emacs session but you need to perform other activities with Linux. In that case, you have several options:
Previous | Table of Contents | Next |