The Emacs Editor

Emacs uses command key combinations to perform word processing tasks. When you read Emacs documentation you will see commands beginning with C- or M-. These are the Control key and the Meta key. On most PCs the Meta key is the Alt key.

Emacs Exercise

  1. To open Emacs, you can do one of the following:

  2. Emacs will display some Help Information, and then show the following screen:

    You can use Emacs on Hercules by remote connection too. Type emacs -nw filename, the -nw switch must be the first switch you use. You will be using a text only interface, but all the keystroke commands will be the same. You may have some difficulty with M- commands when using TeraTerm because Alt opens the terminal's menu. To work around this you can use Esc. Esc has the advantage of being sticky – you don't have to hold it down.

  3. Type C-x C-f and type the file name world.cpp.

  4. You should see a fresh new file. Type the following:
    	#include<iostream>
    
    	using namespace std;
    
    	int main()
    	{
    
    		cout << "Hello World!" << endl;
    
    		return 0;
    
    	}
    
    Do you notice anything about how that was formatted? By default Emacs enforces GNU style C++ formatting.

  5. To save the file as world.cpp type C-x C-s. To save it with a new name type C-x C-w then the new name. Both of these options may be found in the File menu as well.

  6. Type C-x C-c to exit Emacs. Or select Exit Emacs from the File menu.

Congratulations! You have created a file called world.cpp by using Emacs. More practice will definitely prepare you better for the semester. Good Luck with Emacs!

This is just the beginning. Emacs is VERY powerful. It can edit multiple files simultaneously, do complex search and replace, and even run Lisp programs. For more information on Emacs, see the following references: [an error occurred while processing this directive]