Many files on Unix are plain text files. Some examples are text files, markup language files, LaTeX files, source code, Makefiles, and configuration files. Unix utilities also works better with text files. Besides, proper editors help us editing text files productively and effectively. Emacs and Vim are the two most famous editors in Unix world. If you want to enjoy good user experiences on Unix, you may start with Vim or Emacs. Here we take a look at Emacs.
Emacs is an extensible, customizable text editor written in Emacs Lisp. There are dozens of major modes and minor modes for different purposes. Emacs detects files and change modes automatically; you may also change and set modes by yourself. Emacs itself is a self-contained system; many things can be done without exiting Emacs. One joke about Emacs is “What Emacs operating system lacks is a decent editor.” There are several implementations of Emacs, including GNU Emacs, XEmacs, Aquamacs (on OS X) and other variants. The most famous implementation of Emacs is GNU Emacs.
Although there are many different major and minor modes to learn, the basic operations are the same. Open Emacs and press
C-h t to enter the Emacs tutorial. (
C-h t means holding
Ctrl key and press
h key; then, release
h keys and press
t key). The tutorial is not too long to follow.
The help documents in Emacs are important sources to learn Emacs. Here we list some Emacs commands for help; you may start self learning by these commands. Press
C-h ? for help of help, showing all the following commands and more.
There are also some help that helps while writing Emacs Lisp:
If operating Emacs help system is difficult for you, there are also online documents here. Using a web browser is simpler than manipulating Emacs :-). To support Free Software Foundation (FSF) for their great work, consider to buy a print copy of Emacs manual.
Even you are end user, you may need to write a few Emacs Lisp while editing the config file. To customize Emacs, edit ~/.emacs to fit your own need. You don’t have to start everything from the scratch. There have been some solutions on Emacs Manual, Emacs Wiki, or StackOverflow. You may also google some code snippets on the net.
You don’t need to memorize all keybinds of all major modes; stick to basic editing keybinds and commands first; pick up more keybindings and commands gradually. For mainstream text file formats and programming languages, there have been one or more Emacs major mode to handle it. If the mode is not a built-in part of Emacs, you may get it from a third party package.
Beginning at Emacs 24, installing packages becomes easier. Type
M-x list-packages to the Package Menu; choose the packages you want; Emacs will install them for you. You may add marmalade, MELPA, and org repositories for more packages. Edit ~/.emacs to add the three repositories:
There are also some useful mode not for editing tasks. Some of them are:
There are even some modes just for fun. For example, press
M-x doctor and begin to talk to a psychiatrist now.
You may want to give Emacs a try now. Installing Emacs on Linux and Unix is easy. You may use system package manager like
yum to get Emacs. On Mac, download Aquamacs or use MacPorts or Homebrew to get GNU Emacs. Good luck.