Linux / Unix emcas command
Quick links
About emacs
Syntax
Examples
Related commands
Linux / Unix main page
Very nice file edit program that allows you to look at and modify files.
emacs [command-line switches] [files]
| file | Name of the file being edited. |
| +number | Go to the line specified by number (do not insert a space between the "+" sign and the number). |
| -q | Do not load an init file. |
| -u user | Load user's init file. |
| -t file | Use 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 function | Execute the lisp function function. |
| -l file | Load the lisp code in the file file. |
| -batch | Edit 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. |
| -kill | Exit Emacs while in batch mode. |
Using Emacs with X
| -name name | Specifies the name which should be assigned to the initial Emacs window. This controls looking up X resources as well as the window title. |
| -title name | Specifies the title for the initial X window. |
| -r | Display the Emacs window in reverse video. |
| -i | Use the Emacs icon when iconifying the Emacs window. |
| -font font, -fn font | Set 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 pixels | Set 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 pixels | Set 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 geometry | Set 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 color | On color displays, sets the color of the text. See the file /usr/lib/X11/rgb.txt for a list of valid color names. |
| -bg color | On color displays, sets the color of the window's background. |
| -bd color | On color displays, sets the color of the window's border. |
| -cr color | On color displays, sets the color of the window's text cursor. |
| -ms color | On color displays, sets the color of the window's mouse cursor. |
| -d displayname, -display displayname | Create the Emacs window on the display specified by displayname. Must be the first option specified in the command line. |
| -nw | Tells 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 button | Function |
| left | Set point. |
| middle | Paste text. |
| right | Cut text into X cut buffer. |
| SHIFT-middle | Cut text into X cut buffer. |
| SHIFT-right | Paste text. |
| CTRL-middle | Cut text into X cut buffer and kill it. |
| CTRL-right | Select this window, then split it into two windows. Same as typing CTRL-x 2. |
| CTRL-SHIFT-left | X 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-middle | X help menu--pop up index card menu for Emacs help. |
| CTRL-SHIFT-right | Select window with mouse, and delete all other windows. Same as typing CTRL-x 1. |
Basic navigation commands
| CTRL + a | Move to the beginning of the line. |
| CTRL + e | Move 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 + s | Search for text. |
| CTRL + k | Delete line |
| CTRL + - | Undo |
| CTRL + x f | Find a file. |
| CTRL + x c | Quit emacs (will prompt to save if needed). |
| CTRL + g | Quit mini buff |
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.
