|
|
|
What are some basic Emacs commands?
(This page is under construction. I apologize for its appearance.)
Emacs is a powerful extensible text editor. The simplest way to run
emacs is by typing:
emacs
or,
emacs file1 file2 file3 ....
(where file1, file2 etc are the files you want to edit).
We also have an X window enhanced version of emacs installed, called
"xemacs" for users running the X window system.
Emacs has an extensive interactive help facility, but the facility
assumes that you know how to manipulate Emacs windows and buffers.
CTRL-h (backspace or CTRL-h) enters the Help facility. Help Tutorial
(CTRL-h t) requests an interactive tutorial which can teach beginners
the fundamentals of Emacs in a few minutes. Help Apropos (CTRL-h a)
helps you find a command given its functionality, Help Character
(CTRL-h c) describes a given character's effect, and Help Function
(CTRL-h f) describes a given Lisp function specified by name.
Here is a quick index of common Emacs commands. Most of the basic emacs
functions can be invoked with the Control and Escape keys.
| C-x | means hold down the Control key and hit x |
| Esc-x | means hit the Escape key followed by the x
key |
Reading, writing files
| C-x C-f | Find file (to read into buffer) |
| C-x C-s | Save current buffer (ie. file in the buffer) |
Moving the cursor
| C-f | forward character |
| C-b | backward character |
| C-n | next line |
| C-p | previous line |
| |
| |
| C-e | move cursor to end of line |
| C-a | move cursor to beginning of line |
| |
| |
| Esc-< | move cursor to top of document |
| Esc-> | move cursor to bottom of document |
| |
| |
| Esc-f | forward word |
| Esc-b | backward word |
| Esc-a | backward sentence |
| Esc-e | forward sentence |
| Esc-] | forward paragraph |
| Esc-[ | backward paragraph |
| |
| |
| C-v | forward page |
| Esc-v | backward page |
| Esc-x | goto-linen |
| Esc-x | goto-char |
| C-l | recenter and redraw page |
Repeating Commands
ESC-5 C-fmove forward 5 chars
C-u (the universal argument command) - just like Esc-n, but does not
need an argument -> in which case the default of 4 is used. eg:
C-u C-u -> repeat 16 times
Deleting Stuff (Killing)
| C-d | delete char |
| E-d | kill word |
| C-k | kill line (but not newline after it) |
| C-u C-k | delete 4 lines (not 2 lines! - newlines go
too!) |
| E-4 C-k | same |
Yanking back things from the Kill ring
| C-y | yank |
| C-w | kill region |
| E-w | copy region into kill ring |
| C-@ or C-SPC | set-mark |
Paragraph Reformatting
| E-q | fill-paragraph |
| E-g | fill-region |
Searching and replacing
| C-s | isearch-forward |
| C-r | isearch-backward |
| Esc | exit a successful search |
| C-g | quit |
| C-s Esc | non incremental search forward |
| C-r Esc | backward " |
| E-x | replace-string RET bad RET good RET |
| E-% | query replace |
By default, searches are case insensitive. You can change this by
setting the variable: case-fold-search --> set it to: nil (Use Esc-x
set-variable)
| E-x re-search-forward | simple |
| E-x re-search-backward |
| E-x isearch-forward-regexp | incremental |
| E-x isearch-backward-regexp |
| E-x query-replace-regexp |
| E-x replace-regexp | replace unconditionally |
Miscellaneous
| E-x revert-buffer | restore file from disk |
| C-s u | undo |
| |
| |
| C-t | transpose characters |
| E-t | transpose words |
| C-x C-t | transpose lines |
Buffer Manipulation
| C-x b | move to other buffer |
| C-x s | save some buffers |
| E-x kill-buffer | kill buffer |
| E-x kill-some-buffers | kill some buffers |
| E-x rename-buffer | rename buffer |
| C-x C-q | toggle read only status of buffer |
| C-x C-b | list buffers |
Window Manipulation
| C-x 2 | split current window into 2 horizontals |
| C-x 5 | vertically |
| C-x o | move to other window |
| E-C v | scroll next window |
Attach '4' to C-x to have the operation go to the other window, eg:
| C-x 4 f | find-file-other window |
| C-x 4 b | change buffer other window |
| E-x compare-windows | (must have 2 buffers in split
windows) |
Spelling Checker
E-$ (spell check the word the cursor is on)
E-x spell-string
E-x spell-buffer
E-x spell-region
Shell commands in Emacs
| E-! | run UNIX command |
| E-| | run command on marked region
(shell-command-on-region) |
| C-u E-! | run UNIX command, but in the current
window! |
| E-x shell | invoke shell buffer |
to fix echo'ing and ^M ing at the end of lines:
stty -echo nl
Dired: Directory Editor commands
| E-x dired or emacs |
| SPC | move |
| n | next |
| p | prev |
| v | view (via recursive edit) |
| C-c (or q) to return to directory list |
| d | mark for deletion |
| e | edit file |
| f | edit file |
| x | DELETE those marked |
| c | copy file |
| r | rename file |
| M | change file permissions |
Text Formatting
E-x fill-paragraph
E-x fill-individual-paragraphs
E-x edit-tab-stops
E-x untabify (converts tabs to spaces)
E-x tabify
E-x mark-whole-buffer
C-x h variable: indent-tabs-mode
(if set to nil, Emacs always uses spaces to make tabs)
C-x fill-prefix: this string automatically gets inserted at begin of each
line
C-x . set-fill-prefix
E-x indented-text-mode
Centering Text
E-s center-line
E-x center-paragraph
C-l form feed - used for pagination
Defining Macros
C-x ( start macro definition
C-x ) end macro definition
C-x e call-last-kbd-macro
Customizing Emacs
(define-key keymap "keystroke" 'command-name)
(global-set-key "keystroke" 'command-name)
(local-set-key "keystroke" 'command-name)
eg.
(define-key global-map "\C-xl" 'goto-line)
(global-set-key "\C-xl" 'goto-line)
Maps: global-map, ctl-x-map, esc-map
(global-unset-key "\C-s")
Modes
| E-C-\ | indent-region |
| E-m | back-to-indentation |
| E-^ | delete-indentation join this line to previous |
| |
| E-; | indent-for-comment |
C-Mode
| E-C-a | beginning-of-defun |
| E-C-e | end-of-defun |
| E-C-h | mark-c-function |
| Variables | Default |
| c-indent-level | 2 |
| c-auto-new-line | nil |
| c-continued-statement-offset | 2 |
| c-argdecl-indent | 5 |
| c-brace-offset | 0 |
| c-continued-brace-offset | 0 |
| c-brace-imaginary-offset | 0 |
| c-label-offset | -2 |
ETAGS
etags *.[ch] creates a TAGS file
E-. find-tag
C-x 4 find-tag-other-window
E-, tags-loop-continue (find next tag)
E-x tags-search
prompts for an RE and finds it. find next by E-,
E-x tags-query-replace
C-u E-x tags-query-replace (only replace for full words)
E-x list-tags
Lisp Mode
3: emacs-lisp-mode, lisp-mode, lisp-interaction-mode
S-expression: any syntactically correct LISP expression: atom or
parenthesized list.
| E C-a | beginning-of-defun |
| E C-e | end-of-defun |
| E C-h | mark-defun |
Lisp Interaction Mode
E-x lisp-interaction-mode
LINEFEED C-j is bound to eval-print-last-sexp
Compiling Programs withing Emacs
E-x compile
default: make -k (controlled by compile-command variable)
C-c ` next-error
C-u C-x ` start at first error again
E-x grep
Make a New Search
Last modified: Tuesday, 28-May-2002 10:03:37 EDT
|
|