Fun With Emacs

Xah Lee, 2006-01

emacs learning curve

A comic on emacs's learning curve. (from the web 2006-02. Source origin unknown).

You probably heard that emacs can do lots of things, such as running shell, as a file manager, do ftp/sftp, read and send email, read newsgroup forums, and even as a web browser, and lots of other things other than text editing. But you are rather new and don't know how. This page lists some of such fun things you can do right away with emacs. If you don't understand what this page is saying, then goto emacs intermediate.

Split Windows

wildly split emacs screen

Wildly split emacs screen. From top to bottom: calendar, unicode, shell, hex editing mode, HTML mode, file management, calculator.

You can split your window into two or more panes, vertically or horizontally. Type “Ctrl+x 2” to split into two panes, one on top of the other. To move cursor between panes, use “Ctrl+x o”. To go back to a single pane, type “Ctrl+x 1”. To split into side-by-side panes, type “Ctrl+x 3”.

Spliting Window is available under the menu “File‣Split Window”.

View Calendar

To run calendar in emacs, pull the menu “Tools‣Calendar”, or type “Alt+x calendar”.

emacs calendar

A screenshots of emacs's calendar feature.

Calculator

To run a calculator in emacs, type “Alt+x calc”. To compute 1+2, type “1 Enter 2 Enter +”.

To quit calculator, type “q”.

Calculator can also be started by going to the menu “Tools‣Programmable Calculator”.

Converting Numbers to Binary, Octal, Hexadecimal forms.

To convert the decimal 10 to binary representation in calc, type “10 Enter d2”. The d2 will display all numbers in the window in the binary form. The numbers will have a “2#” prefix to indicate that they are in base 2. To display them back in decimal form, type “d0”. To show numbers in octal or hexadecimal form, type “d8” or “d6”.

To convert a binary number 1010 to decimal, type “2#1010 Enter” to enter the number then type “d0” to show all numbers in decimal form. Similarly, to enter a number in octal form, precede it with “8#” and hexadecimal numbers are prefixed with “16#”.

unit conversion

To find out what is 40 F° in C°, type “40 Enter ut dF Enter dC Enter”.

Directory Navigation and Managing Files

A Screenshot of emacs's feature of directory navigation.

Emacs is a excellent tool for file management, such as viewing directory, creating files, copying files, moving files, creating directory, deleting files or directory. Once you become familiar with it, you almost never go back to shell or your operating system's file viewer for these tasks.

For a full tutorial, see: File Management with Emacs.

FTP (or file transfer)

You can also transfer files between different machines connected by a network. The way to do this in emacs is consistent with the way it does directory navigation.

Type “Alt+x d” and type a directory you want to work with. In this directory, suppose myfile.html is the one you want to upload across the network to the machine on “xahlee.org” in the directory “/public_html”. Suppose your login name for that machine is “mary”.

Here's what you do. Type “Ctrl+x d Enter” then move your cursor to the file you want to copy. Type “C” (for copy), then emacs will prompt you for a directory to copy to. Type “/ftp:mary@xahlee.org:/public_html”. You'll be asked for password, then it'll be copied over.

Once you logged in the ftp server, you can actually edit and save files on the remote server, bypassing all the upload/download pain.

Emacs also allows you to do sftp or ftp over ssh.

(info "(emacs)Remote Files")

Colors

To view the many colors and their hexadecimal values in RGB model, type “Alt+x list-colors-display”. This is very useful when you work in HTML.

emacs showing colors

Command Line Interface (aka Shell)

To use emacs as the OS's command line interface (in Mac OS X, Linux, or Windows), type “Alt+x shell”. Now, you can use emacs just as a shell. The advantage is that, you can have the entire shell's screen output history in your window, and you can copy and paste any part you like, just as if it is a normal text file. Normally in a shell, you can visit past command by pressing the up arrow. But now up arrow moves you cursor to the line above. To call the previous command, type “Alt+p”.

For more about running shells in emacs, see: Emacs and Unix Tips.

LISP in Emacs

Sometime you hear that emacs has the artificial intelligence language LISP built in. That's right. Here's how you can run a short example.

In emacs, open a file, any file. In the file, type “(+ 1 2) ”, then move your cursor to the space on the end of the right parenthesis. Now, type “Ctrl+x Ctrl+e”. You will see the result “3”. CONGRADULATIONS, you've just evaluated a lisp program!

For some basics of Emac's LISP, see Emacs Lisp Basics.

Internet Relay Chat (IRC)

If you don't know already, IRC is Internet Relay Chat↗. It's basically like a instant messaging forum.

Yes, you can run IRC in emacs if you are running emacs version 22 or later. To see what version of emacs you have, type “emacs --version” in the command line prompt. Or, inside emacs, type “Alt+x version”.

To start irc, type “Alt+x irc”. Then, you'll be prompted to enter the server name and port and user name, and channel you want to join. For example, use the following:

IRC Server: irc.freenode.net
IRC Port: 6667
IRC Nick: imrandomjack
Channels: #emacs

then you'll be connected to the #emacs discussion room in the irc.freenode.net server.

O My GOD, Too Many Commands

emacs icon

Yeah, that's emacs. Some say, it's a operating system. Others say, it's a overflowing kitchen sink.

Life is filled with endless meaningful things to learn, if it is gonna be a fulfilling life.


Related essays:

2005-10
© 2005 by Xah Lee.