SlideShare a Scribd company logo
emacs: A Mini-Tutorial 
SYNOPSIS 
emacs [ options ] 
DESCRIPTION 
This page intentionally left blank. 
SOURCE 
MIT 
SEE ALSO 
sam(1), vi(1) 
BUGS 
Yes.
emacs 
Emacs is the extensible, customizable, 
self-documenting real-time display 
editor.
But really .. 
• Content sensitive major modes for a wide variety of file types, from 
plain text to source code to HTML files, with syntax coloring. 
• Complete built-in documentation, including a tutorial for new users. 
• Highly extensible through the Emacs Lisp language. 
• Support for many languages and their scripts, including all the 
European メLatin モ scripts, Russian, Greek, Japanese, Chinese, 
Korean, Thai, Vietnamese, Lao, Ethiopian, and some Indian 
scripts. (Sorry, Mayan hieroglyphs are not supported.) 
• A large number of extensions which add other functionality. The 
GNU Emacs distribution includes many extensions; many others 
are available separately ムeven a web browser
emacs 
• Latest Stable Release is 22.1 
• Runs on everything 
• Emacs stands for Editor MACroS
Quick Tour of Emacs 
‘Write’ a simple helloworld app in C 
- Use w3m in emacs to find src code on wikipedia 
- Compile within emacs 
- Demonstrate ease of debugging 
- Use gdb within emacs to run the app
Control and Meta keys 
• `C-x': press the <x> key while holding 
down the <Control> key 
• `M-x': press the <x> key while holding 
down the <Meta> key (typically option, 
but escape always works)
Starting and Quitting 
• To start editing a file: 
– emacs [file] or emacs -nw [file] 
– -nw stands for ‘no window’, useful when 
you don’t want to run XEmacs 
• To quit from emacs: 
– C-x C-c
One cmd to always remember 
C-g 
Quits whatever in the world emacs is 
doing right now. Often you have to use 
it multiple times.
Working with Files 
• Emacs has ‘modes’ associated with filetypes 
and actions (e.g. compilation, debugging) etc. 
– Major mode vs. minor mode 
• Common file commands 
– C-x C-f open file 
– C-x C-s save current buffer 
– C-x s save all open files
Cursor movements 
• These are important because they make you fast 
• Common movement commands 
– C-d delete char 
– C-f forward one char 
– C-b back on char 
– C-n next line 
– C-p previous line 
– C-a beginning of line 
– C-e end of line 
– C-o new line (enter)
Even more cursor movements 
• M-> end of file 
• M-< beginning of file 
• M-d delete word 
• M-f forward one word 
• M-b back one word 
• M-} forward one paragraph 
• M-{ back one paragraph 
… many others (see references)
SearchingReplacing 
• C-s find word forward 
• C-r find word in reverse 
• Use C-s and C-r to jump forwardback 
– Press [enter] to stop the cursor on the current match 
• M-% replace with prompt 
• M-x ‘replace-string’ replace without prompting
Cut and Paste 
• C-[space] set a mark (start of region) 
• C-x C-x jump to 
• C-w cut the region from mark to 
current cursor location 
• M-w copy region 
• C-y paste region 
• C-k cut to end of line, use multiple 
times to add to cut buffer (kill buff)
Working with buffers 
• Buffers -- where editing takes place, but 
they may also contain program output 
• Common commands: 
– C-x b select another buffer 
– C-x C-b list all buffers 
– C-x k kill current buffer
Multiple Windows 
• Useful for having multiple buffers on the 
screen. Make use of all that screen space! 
• Common commands 
– C-x 2 split window horiz 
– C-x 3 split window vert 
– C-x 1 delete all other windows 
– C-x 0 delete this window 
– C-x o jump to ‘other’ window (use to cycle 
through windows).
Macros 
• Macros are useful for repeatable key sequences 
that may be include commands. 
• Common macro commands 
– C-x ( begin macro definition (after this, type 
whatever actions you’d like repeatedstored) 
– C-x ) end macro definition 
– C-e execute stored macro 
– C-u 5 C-e execute stored macro 5 times (Note: C-u 5 
can prefix any emacs cmd, even a non-cmd)
Extras 
• M-x ‘shell’ start a shell in a new buffer! 
• M-x ‘dired’ start a directory editor/browser 
• M-x ‘tetris’ start tetris 
• M-x ‘w3m’ web browser (see refs) 
• M-x ‘gnus’ start reading gnu news 
• M-x ‘compile’ compile cmd, also ‘recompile’ cmd 
• M-x ‘vi-mode’ Vi mode for emacs!
References 
• Reference card with most commands you’ll ever need 
– http://www.clip.dia.fi.upm.es/~logalg/doc/emacsreference.pdf 
• Official GNU emacs site 
– http://www.gnu.org/software/emacs/ 
• An emacs HowTo 
– http://jeremy.zawodny.com/emacs/emacs.html 
• w3m web browser for emacs 
– http://emacs-w3m.namazu.org/index-en.html

More Related Content

PPTX
Passing an Array to a Function (ICT Programming)
PPT
Primitive data types in java
PPTX
Input & Output
PPTX
Pointers in c++
PPT
Structure c
PPT
Instruction Set Architecture (ISA)
PPT
Pass 1 flowchart
PPT
1.1 binary tree
Passing an Array to a Function (ICT Programming)
Primitive data types in java
Input & Output
Pointers in c++
Structure c
Instruction Set Architecture (ISA)
Pass 1 flowchart
1.1 binary tree

What's hot (20)

PPTX
arrays of structures
PDF
Function overloading ppt
PPTX
OOP C++
PPTX
Typedef
PPTX
Data structures using C
PPTX
Structure of dbms
PPTX
Phases of compiler
PPSX
Data type
PPTX
Array and string
PPTX
Data types in c++
PPTX
Real Time Operating Systems for Embedded Systems
PPTX
Floating point representation
PDF
Modular Programming in C
PPT
Array in c
PPTX
Data types
PPT
Client Server Computing : unit 1
PDF
C++ OOPS Concept
PDF
Sql server difference faqs- 4
PPT
Labels and buttons
PPTX
Inheritance in java
arrays of structures
Function overloading ppt
OOP C++
Typedef
Data structures using C
Structure of dbms
Phases of compiler
Data type
Array and string
Data types in c++
Real Time Operating Systems for Embedded Systems
Floating point representation
Modular Programming in C
Array in c
Data types
Client Server Computing : unit 1
C++ OOPS Concept
Sql server difference faqs- 4
Labels and buttons
Inheritance in java
Ad

Viewers also liked (16)

PDF
My Emacs Configs
PDF
Emacs intro
PDF
Emacs - COSCUP 2012
PPT
Emacs, a performant IDE for Perl
PDF
Emacs入门
ODP
Learn Linux: Emacs
PDF
Emacs presentation
PDF
Emacs Modes I can't work without
PDF
Linux boot process
PPTX
Code4vn - Linux day - linux boot process
PDF
How Emacs changed my life
PPT
Linux booting procedure
PDF
(IDEユーザのための) ClojureのEmacs開発環境について
PDF
Using Clojure, NoSQL Databases and Functional-Style JavaScript to Write Gext-...
PDF
我在豆瓣使用Emacs
PPTX
Rhel6 vs rhel7
My Emacs Configs
Emacs intro
Emacs - COSCUP 2012
Emacs, a performant IDE for Perl
Emacs入门
Learn Linux: Emacs
Emacs presentation
Emacs Modes I can't work without
Linux boot process
Code4vn - Linux day - linux boot process
How Emacs changed my life
Linux booting procedure
(IDEユーザのための) ClojureのEmacs開発環境について
Using Clojure, NoSQL Databases and Functional-Style JavaScript to Write Gext-...
我在豆瓣使用Emacs
Rhel6 vs rhel7
Ad

Similar to Emacs tutorial (20)

PDF
unix-editors.pdf
PDF
PDF
KEY
Small Screen Development
ODP
PDF
Tips and Tricks for Increased Development Efficiency
ODP
ODP
Linuxppt
ODP
Nithi
PDF
Intro to .NET and Core C#
PDF
Linux For Beginners! Ultimate guide to Linux Users!!
PPT
Unix Lec2
PDF
Compiler design notes phases of compiler
PPTX
Makefile for python projects
PDF
Linux for beginners
PDF
It's always sunny with OpenJ9
PPTX
PPT4-Windows CLI.pptx
ODP
Linuxs1
PPT
computer languages
PPTX
Basics of C Lecture 2[16097].pptx
unix-editors.pdf
Small Screen Development
Tips and Tricks for Increased Development Efficiency
Linuxppt
Nithi
Intro to .NET and Core C#
Linux For Beginners! Ultimate guide to Linux Users!!
Unix Lec2
Compiler design notes phases of compiler
Makefile for python projects
Linux for beginners
It's always sunny with OpenJ9
PPT4-Windows CLI.pptx
Linuxs1
computer languages
Basics of C Lecture 2[16097].pptx

More from Lingfei Kong (7)

PDF
It经典图书(附免费下载地址)
PDF
Shell实现的windows回收站功能的脚本
PDF
Python学习笔记
PDF
PDF
Device virtualization and management in xen
PDF
Congfigure python as_ide
ODP
SR-IOV Introduce
It经典图书(附免费下载地址)
Shell实现的windows回收站功能的脚本
Python学习笔记
Device virtualization and management in xen
Congfigure python as_ide
SR-IOV Introduce

Emacs tutorial

  • 1. emacs: A Mini-Tutorial SYNOPSIS emacs [ options ] DESCRIPTION This page intentionally left blank. SOURCE MIT SEE ALSO sam(1), vi(1) BUGS Yes.
  • 2. emacs Emacs is the extensible, customizable, self-documenting real-time display editor.
  • 3. But really .. • Content sensitive major modes for a wide variety of file types, from plain text to source code to HTML files, with syntax coloring. • Complete built-in documentation, including a tutorial for new users. • Highly extensible through the Emacs Lisp language. • Support for many languages and their scripts, including all the European メLatin モ scripts, Russian, Greek, Japanese, Chinese, Korean, Thai, Vietnamese, Lao, Ethiopian, and some Indian scripts. (Sorry, Mayan hieroglyphs are not supported.) • A large number of extensions which add other functionality. The GNU Emacs distribution includes many extensions; many others are available separately ムeven a web browser
  • 4. emacs • Latest Stable Release is 22.1 • Runs on everything • Emacs stands for Editor MACroS
  • 5. Quick Tour of Emacs ‘Write’ a simple helloworld app in C - Use w3m in emacs to find src code on wikipedia - Compile within emacs - Demonstrate ease of debugging - Use gdb within emacs to run the app
  • 6. Control and Meta keys • `C-x': press the <x> key while holding down the <Control> key • `M-x': press the <x> key while holding down the <Meta> key (typically option, but escape always works)
  • 7. Starting and Quitting • To start editing a file: – emacs [file] or emacs -nw [file] – -nw stands for ‘no window’, useful when you don’t want to run XEmacs • To quit from emacs: – C-x C-c
  • 8. One cmd to always remember C-g Quits whatever in the world emacs is doing right now. Often you have to use it multiple times.
  • 9. Working with Files • Emacs has ‘modes’ associated with filetypes and actions (e.g. compilation, debugging) etc. – Major mode vs. minor mode • Common file commands – C-x C-f open file – C-x C-s save current buffer – C-x s save all open files
  • 10. Cursor movements • These are important because they make you fast • Common movement commands – C-d delete char – C-f forward one char – C-b back on char – C-n next line – C-p previous line – C-a beginning of line – C-e end of line – C-o new line (enter)
  • 11. Even more cursor movements • M-> end of file • M-< beginning of file • M-d delete word • M-f forward one word • M-b back one word • M-} forward one paragraph • M-{ back one paragraph … many others (see references)
  • 12. SearchingReplacing • C-s find word forward • C-r find word in reverse • Use C-s and C-r to jump forwardback – Press [enter] to stop the cursor on the current match • M-% replace with prompt • M-x ‘replace-string’ replace without prompting
  • 13. Cut and Paste • C-[space] set a mark (start of region) • C-x C-x jump to • C-w cut the region from mark to current cursor location • M-w copy region • C-y paste region • C-k cut to end of line, use multiple times to add to cut buffer (kill buff)
  • 14. Working with buffers • Buffers -- where editing takes place, but they may also contain program output • Common commands: – C-x b select another buffer – C-x C-b list all buffers – C-x k kill current buffer
  • 15. Multiple Windows • Useful for having multiple buffers on the screen. Make use of all that screen space! • Common commands – C-x 2 split window horiz – C-x 3 split window vert – C-x 1 delete all other windows – C-x 0 delete this window – C-x o jump to ‘other’ window (use to cycle through windows).
  • 16. Macros • Macros are useful for repeatable key sequences that may be include commands. • Common macro commands – C-x ( begin macro definition (after this, type whatever actions you’d like repeatedstored) – C-x ) end macro definition – C-e execute stored macro – C-u 5 C-e execute stored macro 5 times (Note: C-u 5 can prefix any emacs cmd, even a non-cmd)
  • 17. Extras • M-x ‘shell’ start a shell in a new buffer! • M-x ‘dired’ start a directory editor/browser • M-x ‘tetris’ start tetris • M-x ‘w3m’ web browser (see refs) • M-x ‘gnus’ start reading gnu news • M-x ‘compile’ compile cmd, also ‘recompile’ cmd • M-x ‘vi-mode’ Vi mode for emacs!
  • 18. References • Reference card with most commands you’ll ever need – http://www.clip.dia.fi.upm.es/~logalg/doc/emacsreference.pdf • Official GNU emacs site – http://www.gnu.org/software/emacs/ • An emacs HowTo – http://jeremy.zawodny.com/emacs/emacs.html • w3m web browser for emacs – http://emacs-w3m.namazu.org/index-en.html