Wednesday, June 10, 2009

Emacs usage (for survival)

When I first opened emacs, I remember being perplexed and was wondering how to go about editing files the way I used to do with MS-Word. No doubt, emacs is very different and if you are a newbie, emacs can be a little intimidating but I assure you, once that minor hurdle has been crossed it is immensely rewarding. Emacs has a rich collection of commands that can be invoked by pressing a combination of keys on the keyboard. In order to make life easy there are a few abbreviations given to the sequences of key commands.
C-<chr> Hold the control key down while typing the character represented by chr. For example, C-f would be: hold the CONTROL key and type f
M-<chr> Hold the Alt key down while pressing the character represented by chr given in brackets
C-<chr1> <chr2> Hold the control key down while pressing chr1, then release both keys and then press chr2 and so on so forth if you get the drift.
In case you are having trouble in reading and understanding the above abbreviations I recommend that you check the following video tutorials : Update: Do check out this link too for some very good content on emacs.
/*some basic commands that serve as gateways to more interesting stuff*/
C-h tThe help tutorial
C-h i Takes you to the info manual in emacs provided it is installed
/* some essential commands*/
C-s Search the current file
C-x C-f Used to find or create a new file
C-gTo cancel some command while midway. For e.g. type C-h and then cancel it with C-g
C-x C-c A neat way to quit emacs
/* A few commands for moving around the text file */
C-f Move forward one character (left arrow)
C-b Move backward one charactber (right arrow)
C-n Move down one line (down arrow)
C-p Move up one line (up arrow)
Similarly C-a, C-e, M-a, M-e, M-b, M-n, M-p are more commands related to moving around the file you are currently editing.Now, you might wonder why there are so many commands related to movement. Well, in case you have not already discovered, I suggest that you find the difference between M-a, M-e, C-a and C-e. Besides the variation in functionality, it is also good to practice moving around using the above commands as it helps you to get used to using the key combination sequences which will later help you do some advanced stuff with emacs.

0 comments:

Post a Comment