Professional Documents
Culture Documents
Part 1
Phil Sung
sipbiapemacs@mit.edu
http://stuff.mit.edu/iap/emacs
Special thanks to Piaw Na and Arthur Gleckler
“Emacs is the extensible, customizable,
selfdocumenting realtime display editor.”
The many faces of Emacs
Emacs edits source code
The many faces of Emacs
Emacs is a hex editor
Mx hexlfindfile
The many faces of Emacs
Emacs does diffs
Mx ediffbuffers
The many faces of Emacs
Emacs is a file manager
Mx dired
The many faces of Emacs
Emacs is a shell
Mx shell
The many faces of Emacs
Emacs is a mail/news client
Mx gnus
The many faces of Emacs
Emacs plays tetris
Mx tetris
Why Emacs?
Provides an integrated environment
●
Same editing commands available everywhere
●
Large set of tools available at all times
●
Move text between tasks easily
Why Emacs?
Easy to extend
●
Elisp for customizing or adding new features
●
Extension code has the full power of Emacs
●
Dynamic environment: no restarting or recompiling
Portable
Today's goal: get the flavor of Emacs
●
Getting started with Emacs
●
Editing tips Examples based on
GNU Emacs 22
●
Demos of useful features
●
Common Emacs concepts
Later...
●
Advanced customization
●
Programming and extending Emacs with Elisp
Prerequisites (sort of)
Emacs basic concepts Take the tutorial
to brush up:
●
Files, buffers, windows, frames
Ch t
Keyboard commands
●
Key commands, prefix keys, Mx, the minibuffer
●
"Cx" means Ctrl+x
"Mx" means Meta+x or Alt+x
Basic tasks
●
Opening and saving files, exiting Emacs
It's all about text manipulation
Text in files
●
grocery lists, HTML, code, ...
Text outside of files
●
shell, debugger, ...
Text as a metaphor
●
dired, gnus, ...
Text as a metaphor: dired
M-x wdired-change-to-wdired-mode
after opening any directory
After editing names
in this buffer, Cx
Cs renames the
modified files
Moving around in buffers
By character or line
Cp
Cb Cf
Cn
Moving around in buffers
Beginning, end of line By screen
●
Ca, Ce ●
Cv, Mv
By word Beginning, end of
●
Mf, Mb buffer
By sentence M<, M>
●
●
Ma, Me
Go to line #
● Mg g
Moving around in buffers
Move multiple lines forward, backward
●
Example: Cu 10 Cp (back 10 lines)
●
Cu prefix generalizes to other commands
Search for text
●
Cs, Cr
Exchange point (cursor) and mark
● Cx Cx
Killing ("cutting") text
Kill line
● Ck
Kill many lines
●
Cu 10 Ck (10 lines)
●
Cu Ck (4 lines)
●
Cu Cu Ck (16 lines)
Killing ("cutting") text
Kill region Kill sentence
● Cw ● Mk
Save without killing Kill ("zap") to next
● Mw occurrence of
character
● Mz CHAR
Yanking ("pasting") text
Yank
● Cy
Yank earlier killed text
●
My (once or more after Cy)
The kill ring
●
Almost all commands which delete text save it for
possible later retrieval
The mark
Remembers a previous cursor position
●
Cx Cx to swap point (cursor) and mark
When you... the mark is set to...
● Cspc ●
where you are
●
M< or M> ●
where you were
●
Search for text ●
where you started
●
Yank text ●
start of inserted text
●
Insert a buffer ●
start of inserted text
The mark
The mark ring
●
Move to a previous mark: Cu CSPC
Mark and point are also used to delineate 'the
region'
●
Many commands operate on the text in the region
●
Set region by setting mark, then moving point
Undo
Undo previous actions
●
C/ or C_ or Cx u
Undo within current region
● Cu C/
The undo model, illustrated
A B C D
The undo model, illustrated
A B C D
This is how most editors other than emacs work:
A B C D
This is how most editors other than emacs work:
A B C D
How emacs handles this situation
A B C D
C'
Bill Gates
Steve Jobs
Eric Schmidt Mx replaceregexp
Larry Ellison \(\w+\) \(\w+\)
with
GATES, Bill \,(upcase \2), \1
JOBS, Steve
SCHMIDT, Eric
ELLISON, Larry