Linux / Unix emcas command

Quick links

About emacs
Syntax
Examples
Related commands
Linux / Unix main page

About emacs

Very nice file edit program that allows you to look at and modify files.

Syntax

emacs [command-line switches] [files]

fileName of the file being edited.
+numberGo to the line specified by number (do not insert a space between the "+" sign and the number).
-qDo not load an init file.
-u userLoad user's init file.
-t fileUse specified file as the terminal instead of using stdin/stdout. This must be the first argument specified in the command line.

The following options are lisp-oriented (these options are processed in the order encountered):

-f functionExecute the lisp function function.
-l fileLoad the lisp code in the file file.
-batchEdit in batch mode. The editor will send messages to stderr. This option must be the first in the argument list. You must use -l and -f options to specify files to execute and functions to call.
-killExit Emacs while in batch mode.

Using Emacs with X

-name nameSpecifies the name which should be assigned to the initial Emacs window. This controls looking up X resources as well as the window title.
-title nameSpecifies the title for the initial X window.
-rDisplay the Emacs window in reverse video.
-iUse the Emacs icon when iconifying the Emacs window.
-font font, -fn fontSet the Emacs window's font to that specified by font. You will find the various X fonts in the /usr/lib/X11/fonts directory. Note that Emacs will only accept fixed width fonts. Under the X11 Release 4 font-naming conventions, any font with the value "m" or "c" in the eleventh field of the font name is a fixed width font. Furthermore, fonts whose name are of the form widthxheight are generally fixed width, as is the font fixed. See xlsfonts for more information.

When you specify a font, be sure to put a space between the switch and the font name.

-bw pixelsSet the Emacs window's border width to the number of pixels specified by pixels. Defaults to one pixel on each side of the window.
-ib pixelsSet the window's internal border width to the number of pixels specified by pixels. Defaults to one pixel of padding on each side of the window.
-geometry geometrySet the Emacs window's width, height, and position as specified. The geometry specification is in the standard X format; see X for more information. The width and height are specified in characters; the default is 80 by 40.
-fg colorOn color displays, sets the color of the text.

See the file /usr/lib/X11/rgb.txt for a list of valid color names.

-bg colorOn color displays, sets the color of the window's background.
-bd colorOn color displays, sets the color of the window's border.
-cr colorOn color displays, sets the color of the window's text cursor.
-ms colorOn color displays, sets the color of the window's mouse cursor.
-d displayname, -display displaynameCreate the Emacs window on the display specified by displayname. Must be the first option specified in the command line.
-nwTells Emacs not to use its special interface to X. If you use this switch when invoking Emacs from an xterm window, display is done in that window. This must be the first option specified in the command line.

The following lists the mouse button bindings for the Emacs window under X11.

Mouse buttonFunction
leftSet point.
middlePaste text.
rightCut text into X cut buffer.
SHIFT-middleCut text into X cut buffer.
SHIFT-rightPaste text.
CTRL-middleCut text into X cut buffer and kill it.
CTRL-rightSelect this window, then split it into two windows. Same as typing CTRL-x 2.
CTRL-SHIFT-leftX buffer menu--hold the buttons and keys down, wait for menu to appear, select buffer, and release. Move mouse out of menu and release to cancel.
CTRL-SHIFT-middleX help menu--pop up index card menu for Emacs help.
CTRL-SHIFT-rightSelect window with mouse, and delete all other windows. Same as typing CTRL-x 1.

Basic navigation commands

CTRL + aMove to the beginning of the line.
CTRL + eMove to the end of the line.
CTRL + x [Move to the beginning of the file.
CTRL + x ]Move to the end of the file.
CTRL + sSearch for text.
CTRL + kDelete line
CTRL + -Undo
CTRL + x fFind a file.
CTRL + x cQuit emacs (will prompt to save if needed).
CTRL + gQuit mini buff

Examples

emacs myfile.txt

Open the file myfile.txt in the emacs text editor. Once open if you wish to quit emacs press CTRL + X + C. Addition CTRL and navigations can be found in the above syntax.

Related commands

xlsfonts
xterm
xrdb