One Editor To Rule Them All - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

One Editor To Rule Them All

Description:

One Editor To Rule Them All Dan Berger dberger_at_cs.ucr.edu Titus Winters titus_at_cs.ucr.edu Introduction The hacker community has a tradition of treating their favorite ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 28
Provided by: danbe6
Learn more at: http://www.cs.ucr.edu
Category:
Tags: editor | misspelled | one | rule | words

less

Transcript and Presenter's Notes

Title: One Editor To Rule Them All


1
One Editor To Rule Them All
  • Dan Berger dberger_at_cs.ucr.edu
  • Titus Winters titus_at_cs.ucr.edu

2
Introduction
  • The hacker community has a tradition of treating
    their favorite text editor with a reverence
    bordering on religious fanaticism Editor wars
    are usually fought between the devottees of Emacs
    and vi, the most popular editors on Unix.
  • - http//wikipedia.org/wiki/Editor_wars

3
Outline
  • A Brief Emacs history
  • Fundamental Emacs Concepts
  • Basic Commands/Key Chords
  • Using Emacs as an IDE
  • Nifty Features
  • Customizing Emacs

4
Emacs A Brief History
  • Originally written in 1976 by Richard Stallman
    (scary dude) as a set of Editor MACroS for the
    TECO editor.
  • Two common strains in the wild Emacs (the one
    were talking about here) and XEmacs (the one
    were not).
  • If you want to know more try WikiPedia/wiki/Emacs

5
Fundamental Emacs Ideas
  • Emacs is essentially a lisp interpreter.
  • No this isnt an elisp hacking seminar.
  • Whats important is that elisp is Turing
    complete
  • That means Emacs is horribly extensible and can
    do anything you can express in elisp (see Turing
    Complete)

6
Terminology
  • A key chord is a set of keys pressed together.
  • Text is stored in buffers often, but not
    always, buffers hold the contents of files.
  • Reading a file into a buffer is called visiting
    the file.
  • Portions of the emacs display are called
    windows
  • Multiple emacs displays are each called a frame

7
More Emacs Ideas
  • Emacs does its work by calling elisp functions
    which are often bound to key chords.
  • Buffers have associated major and minor editing
    modes so the editor can behave differently when
    youre editing C/C code vs. Python code.

8
Basic Commands (I)
  • Starting emacs
  • emacs -nw file1 file2 fileN
  • emacs will run either in GUI mode (under X) or
    tty mode (in a terminal, or with the nw flag)
  • Exiting emacs
  • C-x C-c
  • Control-x Control-c
  • M-x save-buffers-kill-emacs
  • Meta (Alt or Esc)-x save-buffers-kill-emacs

9
Basic Commands (II)
  • Get help C-h
  • Run a tutorial C-h t
  • Open (visit) a file C-x C-f
  • Save a buffer to a file C-x C-s

10
Mark and Selection
  • Manipulating regions of text is easy once you
    understand the mark
  • The mark is one end of the region you want to
    work on the other end is determined by the
    point which is the current cursor position.
  • Set the mark C-spc

11
Manipulating Regions
  • Many emacs commands (can) work on a region of
    text. Remember a region is between the mark
    and the cursor (point).
  • Examples
  • C-w will kill (cut) the selected region
  • Esc-w will copy the selected region
  • C-y yanks (pastes) it back
  • M-x ispell-region will spell check the selected
    region of text.

12
Emacs as an IDE
  • Emacs was written by developers for developers
    so its not surprising that it makes a pretty
    good IDE. You can
  • Write code
  • Navigate code
  • Compile code
  • Debug Code
  • Interface with revision control (CVS)

13
Writing Code
  • Emacs has major modes for just about every
    language you can imagine.
  • It will perform syntax-aware indentation, can
    colorize the code, and is generally aware of
    the structure of the code. So you can jump
    around basic blocks, functions, etc.
  • Each major mode is different C-h m will
    describe the current modes.

14
Navigating Code
  • Emacs includes a support program called etags
    it builds a cross reference (index) of a set of
    files, and helps emacs find symbols.
  • Complete use is outside the scope of this talk,
    but Google can help.

15
Compiling
  • Simple M-x compile
  • By default emacs will run Make but you can run
    any command you want.
  • It will cd into the directory containing the file
    you were visiting when you invoked the compile.
  • This means that you may have to tell make which
    Makefile to use, if its not in that directory.

16
Debugging
  • GUD Grand Unified Debugger mode knows how to
    interface with many standard unix debuggers,
    including gdb (and dbx)
  • M-x gdb
  • M-x pdb
  • M-x jdb
  • An example is worth a thousand words

17
CVS Integration
  • Emacs will recognize if a file (directory) is
    managed by CVS and give you a set of CVS
    commands you can perform without leaving the
    editor including
  • Checkout a file
  • Commit changes to a file
  • Diff a file against the repository
  • Register a new file with revision control

18
Nifty Features
  • font-lock-mode
  • flyspell-mode
  • M-x ispell-comments-and-strings
  • ediff mode
  • tramp

19
Font-Lock-Mode
  • Provides syntax hi-lighting for languages emacs
    understands (many).
  • You can customize the colors it uses and the
    face (font).
  • Turn it on with
  • M-x font-lock-mode
  • Colorize your world with
  • M-x font-lock-fontify-buffer

20
Flyspell-Mode
  • On-the-FLY spell checking.
  • Turn it on with M-x flyspell-mode
  • As you move across text, it gets spell checked.
    Errors are marked.
  • If you want to spell check the entire buffer,
  • M-x flyspell-buffer
  • To see suggested spellings, place the point
    (cursor) on the misspelled word and middle-click
    (or press Esc-)

21
M-x ispell-comments
  • Just what it sounds like it will spell-check
    your code paying attention to comments and
    strings (between quotes).

22
ediff mode
  • diff (the file comparison tool) on steriods.
  • Give emacs two (or three!) files to compare and
    it will help you navigate the differences
    making it easy to update one file with the
    changes in another.
  • M-x ediff-files
  • M-x ediff-buffers

23
tramp
  • A tool for opening files that are not local over
    SSH
  • Any file (anywhere) can be represented as
    /user_at_hostpath/to/file
  • i.e. /titus_at_hill.html/techsem.html
  • Very low bandwidth so its usable over
    slow/unreliable links.
  • Not in the standard Emacs package, but should be
    installed on CS machines soon.

24
Tramp (cont.)
  • If you want to install it on a personal machine
    (Linux or Windows), you can fetch it from
  • http//savannah.nongnu.org/projects/tramp/

25
Customizing Emacs
  • On startup, emacs reads and evaluates /.emacs
    which can contain arbitrary elisp code you want
    executed on startup.
  • My .emacs file (dberger/.emacs) is world
    readable lets take a quick look at it now
  • Recent versions of emacs also include a package
    to help you customize emacs M-x customize will
    get you started.

26
Emacs on MS Windows
  • http//www.gnu.org/software/emacs/windows/
  • The windows portions of Dans .emacs file are old
    and not supported.
  • I havent used Windows in years so Ive no idea
    if that config is still needed or functional.

27
Stuff We Didnt Cover
  • Emacs can be a mail reader, web browser,
    psychologist, and much, much more.
  • We didnt cover elisp the lisp dialect that
    emacs uses theres a good tutorial on-line
  • http//www.gnu.org/software/emacs/emacs-lisp-intro
    /
Write a Comment
User Comments (0)
About PowerShow.com