If you don't like the way something works in EMACS you can change it. If you want a certain key to perform an editing function you can 'bind' it to a custom macro.
The major extensions to EMACS come in the form of lisp packages which can be added as required. These provide features such as:
Other abusive interpretations are:
Now that 8MB is not considered a huge amount of memory all but the last of these has fallen out of use. On my linux box GNU Emacs 20.4 takes up about 5M when resident and around 20Mb of disk space.
Invoke emacs
$ emacs &
Once Emacs is running type 'CONTROL+H' followed by the letter T. This will run the interactive Emacs tutorial. A file called TUTORIAL is loaded which takes you through all the basic steps required to edit files in EMACS. The text directs you step by step in carrying out simple edits on a file.
In general the most frequently used editing sequences are bound to
CONTROL + a letter (written C-letter) or META + a letter
(written M-letter). The ESCAPE key can be used instead of META on
keyboards that do not have a META key. Commands associated with files tend
to be bound to CONTROL + X followed by a letter or another control key
sequence. The CONTROL+X (written C-X) sequence is known as a
prefix and a separate key map is defined for commands invoked
using the same prefix. The common prefixes are:
Key
---
C-X control X
C-X F control X followed by F
M-F meta F or Esc followed by F
M-C-S hold down control + meta + S
where Meta appears you can use ESC
File Handling Searching
------------- ---------
C-X C-F load a file C-S isearch-forward
C-X C-S save file C-R isearch-backwards
C-X C-C exit emacs M-C-S isearch-forward-regexp
C-X C-R view a file M-C-R isearch-backward-regexp
C-X C-W write file (specify filename)
C-X C-Q toggle view mode
C-X I insert-file
C-X S prompt save all buffers
C-X K kill-buffer (unload a file)
C-X 4 f find-file-other-window
C-X 4 r find-file-read-only-other-window
Moving Around Replacing
------------- ---------
C-n next-line (down-arrow) ESC-% query-replace
C-p previous-line (up-arrow) query-replace-regexp
C-f forward-char (right-arrow)
C-b backward-char (left-arrow) Responses During Query Replace
------------------------------
ESC-f forward-word y replace this instance
ESC-b backward-word n dont replace this one
! replace all remaining instances
C-a beginning-of-line . replace this one and exit
C-e end-of-line ^ back up to previous replacement
C-R recursive edit
ESC-a forward-sentence C-M-c exit recursive edit
ESC-e backwards-sentence ? help
q exit
ESC-} forward-paragraph
ESC-{ backwards-paragraph Cut Copy Paste
--------------
ESC-< beginning-of-file C-SPC set-mark-command
ESC-> end-of-file C-w kill-region
C-y yank
C-v scroll-up ESC-w kill-ring-save (copy-region-as-kill)
ESC-v scroll-down C-X h mark whole file
Window Management Changing Case
----------------- -------------
C-X 1 delete-other-windows ESC-C capitalise-word
C-X 2 split-window-vertically ESC-U upcase-word
C-X 3 split-window-horizontally ESC-L downcase-word
C-X o select other window C-X C-U upcase-region
C-X 0 delete this window C-X C-L downcase-region
C-X C-B buffer-menu (? for help)
Deleting Spell Checking
-------- --------------
ESC-d kill-word M-x ispell-buffer
ESC-DEL backward-kill-word M-$ ispell-word
C-d delete-char i accept and insert into dictionary
DEL backward-delete-char a accept for this session
C-k kill-line SPC accept this once
ESC-Z char zap-to-char r replace with typed in word
C-R recursive edit
C-M-c exit recursive edit
x exit
Miscellaneous Transpose
------------- ---------
C-X u undo C-X C-T transpose-lines
C-X m start mail M-T transpose-words
C-C C-W load signature file
C-C C-C send mail
C-Z iconfify emacs window
ESC= count-lines-region
C-X ` next-error
(parse compile errors)
Moving Around Source Code Shell Commands
------------------------- --------------
C-M-F forward-brace ESC-! shell command to buffer (esc bang)
C-M-B backward-brace ESC-| shell command on region (esc pipe)
C-M-A forward-func ESC-x shell RET
C-M-E backward-func (run a shell in a buffer)
Emacs stores a history of commands that have been entered through the minibuffer and commands can be recalled by pressing the up-arrow key.
Also available are the functions isearch-forward-regexp and isearch-backward-regexp which are incremental searches using regular expression matching. These are bound to M-C-s and M-C-r respectively.
Dired (directory): ~/srcThe default path is the last pathname that was entered in the minibuffer. You can use the up-arrow key to recall a previous path and command line completion to complete a partially entered path. Once the return key has been pressed Dired lists the contents of the directory in a manner similar to the ls command.
/root/src: total 56 drwxr-xr-x 14 root root 4096 Apr 30 06:22 . drwxr-x--- 32 root root 4096 May 8 22:33 .. drwxr-xr-x 4 root root 4096 May 8 22:36 emacs-talk drwxr-xr-x 2 root root 4096 May 4 02:45 homepage drwxr-xr-x 2 root root 4096 Apr 18 03:07 keep drwxr-xr-x 2 root root 4096 Jan 16 03:17 misc drwxr-xr-x 2 root root 4096 May 1 23:55 notes drwxr-xr-x 2 root root 4096 Apr 18 03:07 ppp-setup drwxr-xr-x 2 root root 4096 Mar 17 00:14 screenshots drwxr-xr-x 2 root root 4096 Feb 14 20:55 tmp drwxr-xr-x 2 root root 4096 May 5 02:45 web
Here is a sample of the key bindings active when moving the cursor over file entries in a Dired buffer.
Dired (directory): /hughb@bobcat:/ToolsYou are then prompted for the user password of the remote machine.
password for hughb@bobcat:Emacs then opens up an ftp session with the remote machine, requests a directory listing and displays it in a Dired buffer. From then on you can use all the normal Dired commands as previously described. You can can select a file using the cursor, open it for editing using f, edit it and save it back to the remote machine using C-X C-S as if it were a local file. The file gets sent back to the remote machine by the background ftp process. Even hard core vi users go green with envy when they see this in action.
To: Subject: FCC: ~/mail/sent --text follows this line--
(setq mail-archive-file-name "~/mail/sent")
(defconst user-mail-address "Hugh.Barney@whatever.spam.com")
ediff is invoked by entering the minibuffer (M-x) and typing ediff followed by RETURN. You are then prompted for the pathnames for the two files you wish to compare. The screen splits into two windows one above the other and the files are loaded into two buffers A and B. A special control window called the ediff control panel is also created which pops up as a new X Window. Typing various keys whilst the focus is in the control panel enables you perform various ediff functions.
M-x make -k program
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
(setq auto-mode-alist (cons '("\\.html$" . html-helper-mode) auto-mode-alist))
(setq html-helper-do-write-file-hooks t)
The last line enables a timestamp to be updated each time the HTML document
is saved to disk. The timestamp text is delimited by two marker HTML
comments as shown.
<!-- hhmts start --> Last modified: Tue May 9 02:25:54 2000 <!-- hhmts end -->html-helper-mode can be obtained from: http://www.santafe.edu/~nelson/hhm-beta/
(setq-default scroll-step 1) ; turn off jumpy scroll (setq-default visible-bell t) ; no beeps, flash on errors (display-time) ; display the time on modeline (column-number-mode t) ; display the column number on modeline (setq-default kill-whole-line t) ; ctrl-k kills whole line if at col 0 (setq-default fill-column 75) ; wrap at col 75 (setq-default tab-width 4) ; show tabs as 4 cols (setq font-lock-maximum-decoration t) ; use colours in font lock mode (setq font-lock-maximum-size nil) ; trun off limit on font lock mode (add-hook 'c-mode-hook 'customize-cc-mode) ; cc-mode setup ;; some useful key bindings (global-set-key [home] 'beginning-of-line) (global-set-key [end] 'end-of-line) (global-set-key [(control home)] 'beginning-of-buffer) (global-set-key [(control end)] 'end-of-buffer) (define-key esc-map [right] 'kill-word) ;; esc -> kill-word (define-key esc-map [left] 'backward-kill-word) ;; esc <- backward-kill-word ;; Setup Alt Keys (global-set-key [(alt b)] `buffer-menu) (global-set-key [(alt c)] `copy-region-as-kill) ; ESC-w (global-set-key [(alt g)] `goto-line) ;; setup cc-mode (defun customize-cc-mode() (c-set-offset 'substatement-open 0) (setq c-basic-offset 4) (setq c-indent-level 4) (setq comment-column 40) (setq indent-tabs-mode t) (setq c-tab-always-indent nil) (define-key c-mode-map "\C-m" 'newline-and-indent) )
Emacs.geometry: 85x45+70+0 Emacs.font: 9x15 Emacs.background: midnightblue Emacs.foreground: grey90 Emacs.cursorColor: cyan Emacs.pointerColor: cyan Emacs.bitmapIcon: on Emacs.verticalScrollBars: off Emacs.modeline.attributeForeground: black Emacs.modeline.attributeBackground: grey Emacs.region.attributeForeground: black Emacs.region.attributeBackground: grey Emacs.highlight.attributeForeground: black Emacs.highlight.attributeBackground: grey Emacs.secondary-selection.attributeForeground: black Emacs.secondary-selection.attributeBackground: green Emacs.font-lock-function-name-face.attributeForeground: cyan Emacs.font-lock-comment-face.attributeForeground: SpringGreen Emacs.font-lock-doc-string-face.attributeForeground: SpringGreen Emacs.font-lock-preprocessor-face.attributeForeground: cyan Emacs.font-lock-keyword-face.attributeForeground: Yellow Emacs.font-lock-variable-name-face.attributeForeground: Gold Emacs.font-lock-string-face.attributeForeground: Wheat Emacs.font-lock-type-face.attributeForeground: deepskyblue Emacs.info-node.attributeForeground: cyan Emacs.info-node.attributeFont: default Emacs.info-xref.attributeForeground: cyan Emacs.info-xref.attributeFont: default Emacs.bold-italic.attributeForeground:cyan Emacs.italic.attributeForeground:lightgoldenrodyellow Emacs.underline.attributeForeground:gold Emacs.underline.attributeUnderline:no Emacs.bold.attributeForeground:cyan Emacs*menubar.foreground: black Emacs*menubar.background: grey Emacs*menubar.font: 9x15 Emacs*menu.popup.foreground: black Emacs*menu.popup.background: grey Emacs*menu.popup.font: 9x15 Emacs.popup.foreground: black
GNU implementation of Emacs can be downloaded from. http://sunsite.org.uk/gnu/emacs/ Pre-compiled versions also exist for most common platforms.
( emacs-20.6.tar.gz 27-Feb-2000 12:24 14.3M )
The XEmacs consortium implementation can be obtained from: http://ftp.xemacs.org/pub/xemacs/xemacs-21.1/ And you will need the following files.
( xemacs-21.1.9.tar.gz 13-Feb-2000 16:08 6.2M )
xemacs-21.1.9-elc.tar.gz
xemacs-21.1.9-info.tar.gz
http://ftp.xemacs.org/pub/xemacs/packages/
efs-*-pkg.tar.gz
xemacs-base-*-pkg.tar.gz
http://www.xemacs.org/Install/index.html
has install instructions for XEmacs
$ gunzip emacs-20.6.tar.gz $ tar xvf emacs-20.6.tar $ mkdir -p /usr/local/emacs-20.6 $ cd emacs-20.6 $ ./configure --prefix=/usr/local/emacs-20.6 --with-x11 $ make $ make install
Learning GNU Emacs Debra Cameron, Bill Rosenblatt & Eric Raymond O'Reilly & Associates, Inc. ISBN 1-56592-152-6
Writing GNU Emacs Extensions Bob Glickstein O'Reilly & Associates, Inc. ISBN 1-56592-261-1