Philosophy, Principles and Practice Lecture 0: Welcome & - - PowerPoint PPT Presentation

philosophy principles and practice lecture 0 welcome
SMART_READER_LITE
LIVE PREVIEW

Philosophy, Principles and Practice Lecture 0: Welcome & - - PowerPoint PPT Presentation

98-277: The Vim Editor: Philosophy, Principles and Practice Lecture 0: Welcome & Conventions (Hence, not much of meat, but a lot to know) Announcements There will be no class next Monday! (Labour day!) Go out and have fun!


slide-1
SLIDE 1

98-277: The Vim Editor: Philosophy, Principles and Practice

slide-2
SLIDE 2

Lecture 0: Welcome & Conventions

(Hence, not much of meat, but a lot to know)

slide-3
SLIDE 3

Announcements

  • There will be no class next Monday!
  • (Labour day!)
  • Go out and have fun!
slide-4
SLIDE 4

Course Website

http://andrew.cmu.edu/~haoxuany/vim Props to Andrew Benson(adbenson) for creating the amazingly beautiful CSS!!! :) Poll the website for homeworks and announcements!

slide-5
SLIDE 5
  • Course Logistics :(
  • A Bit of Foreshadowing...
  • Installing Vim
  • Keyboard Ergonomics
slide-6
SLIDE 6
  • Course Logistics :(
  • A Bit of Foreshadowing...
  • Installing Vim
  • Keyboard Ergonomics
slide-7
SLIDE 7

whoami

  • Haoxuan "Aaron" Yue (Plz call me Aaron)
  • haoxuany@andrew.cmu.edu
  • School of Computer Science, Class of 2018
  • Started using Vim rougly 6+ years ago
  • Thought it was awful, was miserable (but we'll

talk about it later...)

  • Use Vim exclusively for text editing now
slide-8
SLIDE 8

This is me!

slide-9
SLIDE 9

http://abstrusegoose.com/354

slide-10
SLIDE 10

Before that...

This is a StuCo course!!!

slide-11
SLIDE 11

Meaning...

  • You are REQUIRED to attend class!
  • More specifically, you are not allowed to

miss more than 2 classes. (StuCo policy)

  • (If there are documented illnesses,

emergency situations, university bussiness etc., email me or talk to me preferably BEFORE it happens)

slide-12
SLIDE 12

Meaning...

  • Def Missing Class: Not coming,

Tardiness (miss more than 15 minutes of class).

  • To enforce that, you are REQUIRED to

sign an attendence sheet (during class)

  • Please remember to do that!! It's hard

to verify attendence if you don't.

slide-13
SLIDE 13

Grading

  • Aside from attendance...
  • 40% Homeworks
  • 5 homeworks in total (each 8%).
  • PRINT, finish, and hand it in the next

class after it is assigned.

  • Unless in special circumstances, will not

accept late homework.

slide-14
SLIDE 14

Homework

  • Roughly 3 problems each.
  • 1st problem is basically lecture material.
  • Recommend doing without referencing the

lecture notes.

  • (*May* show up on exams *hint hint*).
  • Other problems extend the discussion in

lecture.

  • Please do them! Very few resources out there

cover these (will talk about that later).

slide-15
SLIDE 15

Grading

  • 30% Midterm
  • 30% Finals
  • Midterm will NOT be curved. Finals may be.
  • Midterm will not cover commands (generally),

hence understand, don't memorize.

  • Final will cover nearly all commands in lecture!
  • Passing requires 60% (under consideration...)
slide-16
SLIDE 16

Grading

  • On a side note
  • It shouldn't be a tough course!
  • Please do all the homeworks!
  • Pay attention in lecture, since the

material is very different from others...

  • Which brings us to...
slide-17
SLIDE 17
  • Course Logistics :(
  • A Bit of Foreshadowing...
  • Installing Vim
  • Keyboard Ergonomics
slide-18
SLIDE 18
  • Course Logistics :(
  • A Bit of Foreshadowing...
  • Installing Vim
  • Keyboard Ergonomics

Yay! :D

slide-19
SLIDE 19

What is Vim?

  • Vim is a text editor.
slide-20
SLIDE 20

What is Vim?

  • Vim is a text editor.
  • This is actually true.
  • Moreover, Vim is a text editor specially

designed for programmers. (Especially C-style programmers, but also works pretty well with other languages).

slide-21
SLIDE 21

A bit more about me...

  • 14 slides ago: "Started using Vim rougly

6+ years ago"

  • Emphasis on the word *started*
  • Then I quit...
slide-22
SLIDE 22

A bit more about me...

  • 15 slides ago: "Started using Vim rougly

6+ years ago"

  • Emphasis on the word *started*
  • Then I ragequit...
slide-23
SLIDE 23

A bit more about me...

  • 16 slides ago: "Started using Vim rougly

6+ years ago"

  • Emphasis on the word *started*
  • Then I ragequit...
  • Well not completely. Picked it up again

sometime around 6 years ago.

  • Then ragequit again. Until finally one

day decided to actually learn it.

slide-24
SLIDE 24

A bit more about me...

  • 17 slides ago: "Started using Vim rougly

6+ years ago"

  • Emphasis on the word *started*
  • Then I ragequit...
  • Well not completely. Picked it up again

sometime around 6 years ago.

  • Then ragequit again. Until finally one

day decided to actually learn? it.

slide-25
SLIDE 25

A bit more about me...

  • 3 weeks. Food + vimtutor.
  • At least 4 hrs of vimtutor drill over and
  • ver and over again.
slide-26
SLIDE 26

A bit more about me...

  • 3 weeks. Food + vimtutor.
  • At least 4 hrs of vimtutor drill over and
  • ver and over and over and over and
  • ver and over and over and over and
  • ver and over and over and over and
  • ver and over and over and over and
  • ver and over and over and over and
  • ver again.
slide-27
SLIDE 27
slide-28
SLIDE 28

Moral of the Story?

  • Vim is hard!
  • Vim is not for mortals like me!
  • Screw that, I'll just use another editor

instead.... Why would I spend so much time on it? (in your case, an entire course)

slide-29
SLIDE 29

Moral of the Story?

  • Vim is hard!
  • Vim is not for mortals like me!
  • Screw that, I'll just use another editor

instead.... Why would I spend so much time on it? (in your case, an entire course)

  • Completely WRONG moral of the story
slide-30
SLIDE 30

Actual Moral of the Story

  • vimtutor is BAD BAD BAD!!!
  • Something you learn in retrospect...
slide-31
SLIDE 31

Something you hear very often...

  • "Vim is hard to learn for beginners"
  • "Vim is great since it has many

commands, which makes you fast"

slide-32
SLIDE 32

Something you hear very often...

  • "Vim is hard to learn for beginners"
  • "Vim is great since it has many

commands, which makes you fast"

  • "<insert random editor name> is better

since it has <insert feature name>."

slide-33
SLIDE 33

Something you hear very often...

  • They are all either wrong, or

unintentionally misleading...

  • They all miss the point!
  • Vim is also not hard to learn, it is just

that most resources out there are complete garbage.

slide-34
SLIDE 34

To list a few...

  • Resources you should

avoid:

  • vimtutor (Worst
  • ffender, probably

should give it some kind of award)

  • Two books from

O'Reilly

  • Also, almost

everything...

slide-35
SLIDE 35

To list a few...

  • Resources you should

avoid:

  • vimtutor (Worst
  • ffender, probably

should give it some kind of award)

  • Two books from

O'Reilly

  • Also, almost

everything...

slide-36
SLIDE 36

To list a few...

  • Resources you should

avoid:

  • vimtutor (Worst
  • ffender, probably

should give it some kind of award)

  • Two books from

O'Reilly

  • Also, almost

everything...

slide-37
SLIDE 37

Actually Good Resources

slide-38
SLIDE 38

Actually Good Resources

  • However, Practical Vim requires some

familiarity with Vim...

  • By that time, most people have already

completed vimtutor :(

  • There are also roughly 3 screencasts

from Destroy All Software, by Gary Bernhardt, though it's a bit pricy...

slide-39
SLIDE 39

Emphasis in this course

  • Systematic use of Vim
slide-40
SLIDE 40

Emphasis in this course

  • Systematic use of Vim
  • Command Clarity and Ergonomics
slide-41
SLIDE 41

Emphasis in this course

  • Systematic use of Vim
  • Command Clarity and Ergonomics
  • Use Cases

– When to use certain commands

slide-42
SLIDE 42

Emphasis in this course

  • Systematic use of Vim
  • Command Clarity and Ergonomics
  • Use Cases

– When to use certain commands – When NOT to use certain commands (antipatterns)

slide-43
SLIDE 43

Emphasis in this course

  • Systematic use of Vim
  • Command Clarity and Ergonomics
  • Use Cases

– When to use certain commands – When NOT to use certain commands (antipatterns)

  • WHY?
slide-44
SLIDE 44

So why this course?

  • Explain HOW to think about text
  • editing. (Philosophy)
slide-45
SLIDE 45

So why this course?

  • Explain HOW to think about text
  • editing. (Philosophy)
  • Explain what RULES we follow when we

manage integration of features, and why some commands are better than others. Also, why we DON'T use some

  • commands. (Principles)
slide-46
SLIDE 46

So why this course?

  • Explains HOW to use Vim commands.

(Practice).

  • And most importantly, throughout the

course explains a fundamental question...

slide-47
SLIDE 47

WHY VIM?

slide-48
SLIDE 48

Word of Warning!!

  • This course does have prerequisites!!!
  • Requires working knowledge of using a unix(-

based/-like) command line

  • basic shell commands (ls, mkdir, cd, ...)
  • some utilities (make, man, ...)
  • it's okay to be bad at shell scripting
  • These commands will NOT be reviewed in

lecture!!

  • There is a course for that:

http://www.cs.cmu.edu/~15131/

slide-49
SLIDE 49

Word of Warning!!

  • This course is in no way "beginner-

friendly", nor is it a crash course.

  • In fact, you should be very wary of

crash courses that tries to explain Vim.

  • We won't even be able to actually use

Vim until roughly the 6th lecture.

slide-50
SLIDE 50

Word of Warning!!

  • Some topics will be covered in much

detail (navigation, repetition...)

  • Some of them will only be covered if

there is time left at the end of the semester (plugins...)

  • This is a new course with brand new

material, so the syllabus should only used as a rough reference.

slide-51
SLIDE 51

Word of Warning!!

  • Some topics will only be briefly

mentioned, because these features are nearly obsolete (marks...)

  • Some topics will be intentionally

avoided! Because they are either broken

  • r its fundamental ideas are WRONG

(vimscript, vim regular expressions, certain plugins)

slide-52
SLIDE 52
  • Course Logistics :(
  • A Bit of Foreshadowing...
  • Installing Vim
  • Keyboard Ergonomics
slide-53
SLIDE 53
  • Cool thing about Vim is that it is

*mostly* designed to be portable.

  • *mostly*
  • However, it doesn't run on your toaster.
  • (maybe if you really try).
  • For the purposes of this course, we will

be using a very specific version of Vim.

slide-54
SLIDE 54

Requirements

  • For this particular course, you need Vim

7.4 huge version with ruby support.

  • (Huh?)
  • First thing to know is that every

subversion upgrade introduces quite a few important changes.

  • Vim 7.3 *may* work, but do not depend
  • n it.
slide-55
SLIDE 55
  • Vim comes in different flavors...
  • tiny
  • small
  • normal
  • big
  • huge
  • There is very little reason not to use

the huge version...

slide-56
SLIDE 56

Check Version

  • vim --version
  • (good idea to pipe into less)
  • Within vim:
  • :version<CR>
  • <CR> stands for "Carriage Return". For
  • ur purposes, it's the Enter key on the

keyboard.

slide-57
SLIDE 57
slide-58
SLIDE 58
slide-59
SLIDE 59

Ruby Support

  • The only reason for this requirement is

that there is a very specific plugin that we will talk about called Command-T:

  • https://github.com/wincent/Command-T
  • Requires vim compiled with ruby support
  • vim --version | grep ruby
  • Make sure that there is a "+" sign next

to "ruby".

slide-60
SLIDE 60

Ruby Support

  • Also requires a "compatible" ruby

version installed in system.

  • Read the plugin README markdown on

github, gives you all the details for that.

  • Also requires a C compiler, highly

unlikely that you don't have one.

slide-61
SLIDE 61

OS woes

  • Some operating systems are very

uncooperative...

  • In fact, one specific operating system

comes to mind.

  • We'll try workarounds, for time being,

here's a general guide.

slide-62
SLIDE 62

Linux (okay, GNU/Linux)

  • Assume that you know what you are

doing... (probably hear that pretty

  • ften).
  • For ubuntu-based systems, apt-get has

precompiled packages

  • sudo apt-get install vim vim-common

vim-nox vim-runtime

  • vim-gtk?
  • vim-nox contains ruby support
slide-63
SLIDE 63

Unix based OSes

  • Also assume you know what you are

doing...

  • Package managers are the way to go.
  • For Macs, I believe homebrew has

macvim packages.

  • According to the website, macvim has

all features of Vim 7.4.

  • I don't own a Mac.
slide-64
SLIDE 64

Windows (ugh)

  • Would be a good time to reflect on your

life choices...

  • Why are you even using Windows for

development?

  • Also does not have prebuilt unix utilites,

such as make, grep, etc.

  • Insanely hard to work with.
slide-65
SLIDE 65

Windows

  • With that said, I could not get Vim on

Windows to work. :(

  • I've tried many many things: compile

from source (doesn't work with rubygems), gvim (also doesn't work with rubygems), Cygwin (doesn't work with anything).

  • If anyone knows workarounds, email me

and I'll post it.

slide-66
SLIDE 66

Temporary Workaround

  • For those who use Windows or those

who do not fit in either category

  • Use SSH, requires andrewid
  • First, you need an ssh client (only

applies to Windows users)

  • PuTTy has some saner colorschemes.
  • Cygwin (along with its tools) is actually

pretty nice.

slide-67
SLIDE 67

Temporary Workaround

  • Update!: As of writing, computing

services just installed the required vim version for this course :D

slide-68
SLIDE 68

Temporary Workaround

  • Update!: As of writing, computing

services just installed the required vim version for this course :D

slide-69
SLIDE 69

Temporary Workaround

  • Put this in your .bashrc over AFS

timeshares:

  • alias vim='vim74'
  • alias vimdiff='vim -d'
  • alias vi='vim'
slide-70
SLIDE 70

Temporary Workaround

  • Put this in your .bashrc over AFS

timeshares:

  • alias vim='vim74'
  • alias vimdiff='vim -d'
  • alias vi='vim'
  • (OPTIONALLY):
  • alias vimtutor='clear && @#$% you!'
slide-71
SLIDE 71

Temporary Workaround

  • Put this in your .bashrc over AFS

timeshares:

  • alias vim='vim74'
  • alias vimdiff='vim -d'
  • alias vi='vim'
  • (OPTIONALLY):
  • alias vimtutor='clear && @#$% you!'
  • Outdated again! (default is vim7.4)

4-letter curse word of your choice

slide-72
SLIDE 72

Temporary Workaround

  • We will be installing Vim in AFS with

andrew linux/unix.

  • In short:
  • Dowload Vim:

ftp://ftp.vim.org/pub/vim/unix/vim- 7.4.tar.bz2

  • untar/unbzip
  • Make with options
slide-73
SLIDE 73

Temporary Workaround

  • As per unix standards...
  • First cd to src directory...
  • make distclean
  • ./configure --with-features=huge --

enable-rubyinterp

  • Now add the directory to your $PATH
slide-74
SLIDE 74
  • Course Logistics :(
  • A Bit of Foreshadowing...
  • Installing Vim
  • Keyboard Ergonomics
slide-75
SLIDE 75

A bit of a history lesson

  • Back in the good ol' days.
  • ed
slide-76
SLIDE 76

A bit of a history lesson

  • Back in the good ol' days.
  • ed
  • while(scanf("%s", str) != EOF)

– printf("?\n");

slide-77
SLIDE 77

A bit of a history lesson

  • em
  • "editor for mortals"
  • en
  • redesigned into ex (by Bill Joy)
slide-78
SLIDE 78

A bit of a history lesson

  • then there's vi.
  • pronouced "vee-eye"
  • Stands for "Visual mode" (literally)
  • Modes <- very central
slide-79
SLIDE 79

A bit of a history lesson

  • Licensing issues...
  • -> "vi clones": elvis, nvi, etc.
  • Vim
  • Note that in this course, we will be talking

about Vim specifically, not vi

  • There are very important differences!!
slide-80
SLIDE 80

A bit of a history lesson

  • "Vim"
  • Stands for "Vi IMitation" initally...
  • Now, it stands for "Vi IMproved"!
  • Drastic improvements.
slide-81
SLIDE 81

Why do we care?

slide-82
SLIDE 82

Why do we care?

  • Because software isn't the only thing

that changed over the years...

  • vi first written in 1976..
  • with ADM-3...
  • Hardware also changed as well.
slide-83
SLIDE 83

Keyboards

What it looked like in the good ol' days

slide-84
SLIDE 84

Keyboards

What it looked like in the good ol' days

slide-85
SLIDE 85

Keyboards

  • The keyboards back in the good ol' days

are surprisingly well-designed!

  • (the key placements at least)
  • There are still problems. Many.
slide-86
SLIDE 86

Standard Keyboards

slide-87
SLIDE 87

Standard Keyboards

slide-88
SLIDE 88

Standard Keyboards

More obvious issue: 3 hands?!?

slide-89
SLIDE 89

Standard Keyboards

  • Mouse... Same issues
slide-90
SLIDE 90

http://xkcd.com/1530/

slide-91
SLIDE 91

Standard Keyboards

  • For the purposes for this course, we

shall pretend that those areas and the mouse do not exist.

  • They're just a figment of your

imagination.

slide-92
SLIDE 92

Standard Keyboards

slide-93
SLIDE 93

Standard Keyboards

Um...

slide-94
SLIDE 94

Standard Keyboards

Um...

slide-95
SLIDE 95

Standard Keyboards

Um...

slide-96
SLIDE 96

Standard Keyboards

Um...

slide-97
SLIDE 97

Standard Keyboards

Solution? Ergonomics Split Keyboard!

slide-98
SLIDE 98

Split Keyboards

slide-99
SLIDE 99

Split Keyboards

slide-100
SLIDE 100

Split Keyboards

Microsoft Natural Ergonomics 4000

slide-101
SLIDE 101

Split Keyboards

  • You can still get Carpal Tunnel if you use

Vim!!

  • Significantly better than emacs

keybindings, still...

slide-102
SLIDE 102

Split Keyboards

  • There are two modifier keys Vim uses:
  • Control: <C->
  • Shift: <S-> (usually no explicit notation)
slide-103
SLIDE 103

Keyboards

slide-104
SLIDE 104

Keyboards

Eh..

slide-105
SLIDE 105

Keyboards

Eh..

slide-106
SLIDE 106

Keyboards

Control

slide-107
SLIDE 107

Legitimate reasons not to remap your Caps Lock key

slide-108
SLIDE 108

Legitimate reasons not to remap your Caps Lock key

  • 1. Skyrim
slide-109
SLIDE 109

Legitimate reasons not to remap your Caps Lock key

  • 1. Skyrim
  • 2. Batman: Arkham
slide-110
SLIDE 110

Legitimate reasons not to remap your Caps Lock key

  • 1. Skyrim
  • 2. Batman: Arkham
  • 3. Balanced Keyboarding (N/A if you're

using a laptop). http://ergoemacs.org/emacs/swap_CapsL

  • ck_Ctrl.html
slide-111
SLIDE 111

Legitimate reasons not to remap your Caps Lock key

slide-112
SLIDE 112

Legitimate reasons not to remap your Caps Lock key

"Pop up"

slide-113
SLIDE 113

Legitimate reasons not to remap your Caps Lock key

  • 1. Skyrim
  • 2. Batman: Arkham
  • 3. Balanced Keyboarding (N/A if you're

using a laptop). http://ergoemacs.org/emacs/swap_CapsL

  • ck_Ctrl.html

Typing all Caps? Not a problem in Vim

slide-114
SLIDE 114

Remapping Caps Lock

  • For the purposes of this course, we

won't be delving that deep into ergonomics.

  • Windows: AutoHotKey (can be turned
  • ff)

http://vim.wikia.com/wiki/Map_caps_loc k_to_escape_in_Windows

slide-115
SLIDE 115

Remapping Caps Lock

  • Macs:
  • https://stackoverflow.com/questions/15

435253/how-to-remap-the-caps-lock- key-to-control-in-os-x-10-8

slide-116
SLIDE 116

Remapping Caps Lock

  • Linux/GNU Linux/Unix/Unix-

like/Other:

  • Assume you know what you're doing...
  • check system settings
  • xmodmap
  • Google (shouldn't be too hard)
slide-117
SLIDE 117

Aside

  • When Vim was designed, it used the

QWERTY layout....

  • Sorry Dvorak users...
  • I don't know how to type dvorak, some

people have some experience with Vim + dvorak, google them

slide-118
SLIDE 118

Finally

slide-119
SLIDE 119

Finally

slide-120
SLIDE 120

Finally

"Bad" Ergonomics "Good" Ergonomics

slide-121
SLIDE 121

Next Time

  • The Vim Philosophy (2 most important

lectures in the course!!)

  • How do we think about text editing?
  • What does it mean for an editor to edit text?
  • Please set up Vim, and remap your keys!
  • Study the keyboard layout carefully.
  • Remember, no class next Monday!