EDITOR

CCCA

About Me

Peter

package management system

Bash on Windows

Apt

Different Platform

  • Ubuntu: Apt
  • OSX: homebrew
  • FreeBSD: pkg
  • Arch linux: pacman
  • etc.

Command: Ubuntu

  • sudo add-apt-repository ppa:kelleyk/emacs
  • sudo apt update
  • sudo apt install emacs-nox

Command: OSX

  • brew tap railwaycat/emacsmacport
  • brew install emacs-mac

Command: FreeBSD

  • sudo pkg install emacs-nox11

Introduction

Why text editor?

Why text editor?

Why text editor?

  • lite weight
  • highly customizable
  • convenient for remote work

How to learn?

How to learn?

How to learn?

Text Editors

In the old days

  • ee
  • vi

nowadays

  • nano
  • Vim
  • Emacs

Text Editors

editors

Vi

jokes

jokes

Not today

but for survival

This Thursday EC330 7:00

Don't miss it

Mode

  • Normal mode
  • Insert mode
  • etc.

Normal mode

  • Move cursor
  • change mode
  • enter command

Insert mode

  • edit file content

Progress

Open file

$ vi a.txt

$ vi  filename

Move cursor

enter "i"

"ESC"

back to Normal mode

edit

delete?

backspace & delete not working QQ

delete!

  • X == delete char before cursor 
  • x == delete char after cursor

Insert or Append?

edit

  • i == write before cursor 
  • a == write after cursor

"ESC"

back to Normal mode

":"

Enter Command

Exit Vi

  • :q == quit
  • :wq == write & quit
  • :q! == suspend changes & quit

Survival!!

Emacs

Emacser?

Keys

  • Ctrl
  • alt
  • esc
  • super
  • hyper
  • meta

old keyboard

EMACS == Esc + meta + alt + ctrl + shift

So many keys

so hard to remember

Don't worry

Let's start

highly customizable

with emacs lisp

lisp

  • (+ 1 2 3 4 5) == 15
  • (defun f  (x)  (*  x  x)) == f(x) = x^2

Emacs

a lisp enviornment

everything is a

lisp function

keys

  • Ctrl == C
  • Meta == M == ESC or alt
  • "C-g" == Ctrl + g

we bind functions to keys

M-x

select a lisp function

cheatsheet

Move

  • C-p -> previous
  • C-n -> next
  • C-f  -> forward
  • C-b -> backward

Move

  • C-a -> line head
  • C-e -> line end
  • M-< -> file head
  • M-> -> file end

Move

  • C-v -> next page
  • M-v -> previous page

Mark

  • C-@ -> mark start

delete

  • backspace | delete
  • C-d
  • C-@ + delete

kill?

  • C-k
  • C-@ + C-w
  • M-d

Kill & Yank!

yank

  • C-y

kill ring

kill ring

  • kill -> into kill ring
  • C-y -> yank from ring
  • (C-y) M-y  -> rotate ring

Copy(into kill ring)

  • C-@ + M-w

Search

  • C-s
  • C-r

replace

  • M-%

split windows

  • C-x 2 -> row 
  • C-x 3 -> col
  • C-x 1  -> close others
  • C-x 0 -> close this

macro (record keys)

  • C-x (    -> start record
  • C-x )    -> end record
  • C-x e   -> execute

save & quit

  • C-x C-s -> save
  • C-x C-c -> quit
  • C-x C-w + /path -> write to path

Packages

~/.emacs.d/

spacemacs

demo

Q&A

EDITOR

By Peter Cheng

EDITOR

  • 946