![]() |
|
|
|
|
|
Emacs: The programmer's editor
By Vans Information <content@vansinfo.com>
Emacs is one of the most preferred editors under Linux. This full-featured screen-based editor has gained enormous popularity due to its ease of use and extensibility. One can be sure that while using emacs, one won't end up in a nightmare situation, as is usually the case with an editor like 'vi'. Although used more often on a Unix-based system, emacs has been ported on a wide variety of Unices as well as DOS and Windows. On the GNU-Linux-based system, it is available in text mode and as an X application. You can invoke emacs from the command prompt by the following command: The above command name may be followed by a list of one or more filename(s) that are to be opened. As soon as emacs starts up, it takes over your screen. Usually you see a Scratch-pad available for you. This brings us to the structure of the emacs editor, which usually comprises in-memory buffers. The Scratch-pad is a buffer where you can key in text and later convert it to a named document. Just like other editors emacs allows you to open multiple files at a time. Also it provides support for many programming languages including C, C++, Java, SGML, TeX, etc. It has modes for various languages, where it undertakes syntax checks like checking for braces and parentheses. Whenever you open a text file containing program code, emacs detects the programming language, and initiates the appropriate mode. Given below are some of the basic commands. Opening a file In order to open a file from within emacs, you need to use the command Ctrl-X F. Here the X & F need to be pressed in succession. This is the way most of the commands are entered. Upon issuing the above command, the cursor moves to the bottom of the screen. The last line of the screen is called the Mini-buffer. This is the area where all commands are issued and messages are displayed. Here, enter the name of the file you want to open. If the file is non-existent, then a new file with the given name is created. Now the cursor moves over to the top-left of the emacs screen. Here you can type in your text as in a normal editor using arrow keys for movement and the usual backspace and Del keys. Later in this article, we look at some of the more advanced commands. Saving a file The command to save a file is Ctrl-X S. Emacs saves the contents of the modified file in memory to disk. In effect, emacs only does a buffer write. The rest of the buffers that can be holding contents of other files are not updated on disk. To save the file under some other name use the 'Save As' command which is given as Ctrl-X W. After issuing this command, emacs will you to specify the new name for the current file. Quitting emacs To quit emacs, the command usually given is Ctrl-X C. This command finishes the current emacs session and returns you to the shell prompt. If files opened in their respective buffers have not been saved, emacs gives a prompt for each file asking the user whether he/she wishes to save the file. You can also suspend emacs operation so that it temporarily spawns a shell where you can issue commands to the operating system. Issuing the Ctrl Z command can do this. You can return to emacs by typing 'fg' at the command prompt. Given below are some basic commands to help you start off. Ctrl A beginning of the line.
Ctrl V Scrolls forward by one screen.
In case you have opened multiple files in emacs, you need different buffers to store them as one buffer can hold only one file. At any time, only one buffer is active. To switch to another buffer, we can issue the command Ctrl B The following `delete’ operations can be performed. Del deletes the character just before the cursor The word 'kill', instead of deleting, is used to signify that the set of characters thus `killed’ have been saved into a special 'clipboard' area. They can be 'yanked’ meaning that they can be pasted to the current position using Ctrl Y. This operation is similar to the Cut-&-Paste, as we see in most MS-Windows systems. Emacs, however, is a lot more than what we have just seen. We hope this article will encourage you to use it.
Other articles by Vans Information
Current Rating: [ 5.83 / 10 ]
Number of Times Rated: [ 35 ]
|
|
|
© 1998-2004 FreeOS Technologies (I) Pvt. Ltd. All rights reserved.
[Privacy Policy]
![]() |