User:Brian Smith/Emacs Reference

From CSWiki

< User:Brian Smith
Revision as of 12:25, 8 March 2009 by Corona (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

I compiled these from a few online sources and the tutorial in emacs. If you find anything that should be changed just email me.


Contents

[edit] General

press and hold the CTRL key                        C-

press and hold META key (ALT on Windows)           M-

give an argument to command                        C-u [command]

give a numerical argument # to command             C-u # [command]

abort partially typed or executing command         C-g

Undo last command(s)                               C-x u  OR  C-_

exit Emacs (asks about saving modified files)      C-x C-c 

[edit] Files and Buffers

create new or read existing file                   C-x C-f

save a file to disk                                C-x C-s

write file with different file name                C-x C-w

list current buffers                               C-x b

insert contents of another file into this buffer   C-x i

save modified buffers (user choice)                C-x s 

Revert current buffer                              M-x revert-buffer <Return>

Kill current buffer                                C-x k

[edit] Windows

Display only current window                        C-x 1

Split screen into two windows                      C-x 2

Move cursor to other window                        C-x o

[edit] Moving the view

Forward/backward one screenful                     C-v / M-v

Clear screen, redraw, center on cursor             C-l  (lower case L)

[edit] Moving the cursor in a file

Forward/backward one character                     C-f / C-b  (also arrow keys)

Forward/backward one word                          M-f / M-b

Previous/Next line                                 C-p / C-n  (also arrow keys)

Beginning/End of current line                      C-a / C-e

Beginning/End of current sentence                  M-a / M-e

Beginning/End of whole text                        M-< / M->

Goto line                                          M-x goto-line <Return>,
                                                   n <Return>

Mark and return cursor to point in file            C-x /[character] to mark,
                                                   C-x j[character] to jump back

[edit] Manipulating text

Note that when you delete text more than one character at a time, it is saved so you can bring it back. Instead of 'deleting' this is called 'killing', and bringing it back is called 'yanking'.

Repeat a character n times                         C-u n [character to repeat]

Transpose characters to left of cursor             C-t

Transpose current and previous line                C-x t

Remove all whitespace to left of cursor            M-\


Delete the character before/after cursor           <Delete> / C-d

Kill the word before/after cursor                  M-<Delete> / M-d

Kill to end of current line/sentence               C-k / M-k

Yank most recent text that has been killed         C-y

Yank previous kills                                C-y then M-y


Kill/Copy a specified block                        C-@ or C-<Space>,
                                                   move cursor forward,
                                                   kill with C-w, copy with M-w

Kill a rectangular block                           C-@ or C-<Space>,
                                                   move cursor forward,
                                                   C-x C-x,
                                                   M-x kill-rectangle <Return>

Yank a rectangular block                           M-x yank-rectangle <Return>

Store and retrieve frequently used text            C-x x[character] to save,
                                                   C-x g[character] to get text

[edit] Search and Replace

Incremental Search forward/backward                C-s / C-r,
                                                   enter search term,
                                                   C-s / C-r to go to next occurrence,
                                                   <Return> to exit

Basic Replace                                      M-%,
                                                   enter search and replacement terms,
                                                   y to replace, n to skip,
                                                   . to replace and exit,
                                                   ! to replace all following matches,
                                                   ^ to go back one match,
                                                   <Return> to exit

Regular Expression Search                          C-M-s / C-M-r,
                                                   enter search regular expression,
                                                   C-s / C-r to go to next occurrence,
                                                   <Return> to exit
                                                   


[edit] Oz-specific Emacs commands

[edit] Oz Buffers

Create new Oz buffer                               C-. n

Previous/Next Oz buffer                            M-p / M-n

[edit] Editing code

Note that an Oz definition is the text inside a proc, fun, class or meth up to it's matching end. An Oz expression is either a bracketed Oz construct (such as proc...end or local...end) or a single word.

Forward/backward Oz expression                     C-M-f / C-M-b

Beginning/End of current Oz definition             C-M-a / C-M-e

Kill Oz expression                                 C-M-k

[edit] Executing code

Feed buffer/region/line                            C-.  AND  C-b / C-r / C-l

Evaluate and Browse buffer/region/line             C-. b  AND  C-b / C-r / C-l

Evaluate and Show buffer/region/line               C-. s  AND  C-b / C-r / C-l