Slide 1

Slide 1 text

VIM “If people knew how hard I had to work to gain my mastery, it would not seem so wonderful at all” Michelangelo Buonarroti craftsman’s precision tool

Slide 2

Slide 2 text

QUICK HISTORY 1971 - ed text editor by Ken Thompson

Slide 3

Slide 3 text

QUICK HISTORY 1971 - ed text editor by Ken Thompson 1976 - ex (EXtended) by Bill Joy 1976 - vi (visual mode for ex) by Bill Joy 1991 - vim (vi improved) by Bram Moolenar

Slide 4

Slide 4 text

VIM is not VI VI - ancient 1976 technology VIM - state of the art 1991 editor VIM introduced more new features, than vi had overall in its lifetime

Slide 5

Slide 5 text

YOU DON’T LIKE VIM because you don’t get it

Slide 6

Slide 6 text

YOU DON’T LIKE VIM because you don’t get it and it’s ok!

Slide 7

Slide 7 text

YOU DON’T LIKE VIM because you don’t get it and it’s ok! it’s different from newbie-friendly visual editors it requires some (major) investment from the user, aka “the learning curve”

Slide 8

Slide 8 text

TO EACH HIS OWN

Slide 9

Slide 9 text

TO EACH HIS OWN some like it straight

Slide 10

Slide 10 text

TO EACH HIS OWN some like it straight some like it curvy

Slide 11

Slide 11 text

THE MODAL EDITOR

Slide 12

Slide 12 text

THE MODAL EDITOR Every BUTTON performs a different function in a different mode

Slide 13

Slide 13 text

THE MODAL EDITOR Every BUTTON performs a different function in a different mode do you think it’s weird and uncommon? think again

Slide 14

Slide 14 text

THE MODAL WORLD What would you rather use? This (could you even tell what every button is for?)

Slide 15

Slide 15 text

THE MODAL WORLD What would you rather use? This (could you even tell what every button is for?) or this

Slide 16

Slide 16 text

THE MODAL MIND You’re a craftsman - think first, edit later

Slide 17

Slide 17 text

THE MODAL MIND You’re a craftsman - think first, edit later think about what you’re doing

Slide 18

Slide 18 text

THE MODAL MIND You’re a craftsman - think first, edit later think about how you’re doing it

Slide 19

Slide 19 text

THE MODAL MIND You’re a craftsman - think first, edit later and ONLY THEN do it

Slide 20

Slide 20 text

MOVING AROUND IDEAL: follow the eye

Slide 21

Slide 21 text

MOVING AROUND IDEAL: follow the eye Mouse is actually close enough

Slide 22

Slide 22 text

MOVING AROUND IDEAL: follow the eye Mouse is actually close enough Especially with enough target practice

Slide 23

Slide 23 text

MOVING SLOWLY But mouse targeting is slow

Slide 24

Slide 24 text

MOVING SLOWLY But mouse targeting is slow FITT’S LAW The time required to rapidly move to a target area is a function of the distance to and the size of the target

Slide 25

Slide 25 text

MOVING SLOWLY But mouse targeting is slow and tiresome and boring while  (!onTarget)  do moveTowardsTarget end so many wasted brain cycles

Slide 26

Slide 26 text

MOVING SLOWLY But mouse targeting is slow and tiresome and boring and breaks the flow

Slide 27

Slide 27 text

MOVING ROUGHLY Keyboard is usually ok (even in Notepad) imaging doing that on that teletype with unlimited applications...

Slide 28

Slide 28 text

MOVING ROUGHLY Keyboard is usually ok (even in Notepad) but only if you need to hit BIG targets (top/bottom of the file, start/end of the line) imaging doing that on that teletype with unlimited applications...

Slide 29

Slide 29 text

MOVING ROUGHLY Keyboard is usually ok (even in Notepad) but only if you need to hit BIG targets (top/bottom of the file, start/end of the line) Hunting for smaller targets (specific chars/lines): while  (!onTarget)  do moveTowardsTarget end imaging doing that on that teletype with unlimited applications...

Slide 30

Slide 30 text

MOVING PATTERNS average text editor

Slide 31

Slide 31 text

MOVING PATTERNS Above average text editor

Slide 32

Slide 32 text

MOVING PATTERNS Above average text editor VIM

Slide 33

Slide 33 text

MOVING PATTERNS Above average text editor VIM Knight in a single move hits a target that takes a queen 2 moves to hit

Slide 34

Slide 34 text

TARGET HITTING 101 The  quick  brown  fox  jumps  over  the  lazy  dog.

Slide 35

Slide 35 text

TARGET HITTING 101 The  quick  brown  fox  jumps  over  the  lazy  dog. f l The  quick  brown  fox  jumps  over  the  lazy  dog.

Slide 36

Slide 36 text

TARGET HITTING 102 The  quick  brown  fox  jumps  over  the  lazy  dog.

Slide 37

Slide 37 text

TARGET HITTING 102 The  quick  brown  fox  jumps  over  the  lazy  dog. f o The  quick  brown  fox  jumps  over  the  lazy  dog.

Slide 38

Slide 38 text

TARGET HITTING 102 The  quick  brown  fox  jumps  over  the  lazy  dog. f o The  quick  brown  fox  jumps  over  the  lazy  dog. ;

Slide 39

Slide 39 text

TARGET HITTING 102 The  quick  brown  fox  jumps  over  the  lazy  dog. f o The  quick  brown  fox  jumps  over  the  lazy  dog. ; ;

Slide 40

Slide 40 text

TARGET HITTING 102 The  quick  brown  fox  jumps  over  the  lazy  dog. f o The  quick  brown  fox  jumps  over  the  lazy  dog. ; ; ;

Slide 41

Slide 41 text

TARGET SELECTION Better targets: punctuation special characters (@, &, $) uppercase letters etc

Slide 42

Slide 42 text

TARGET SEARCH Learn to love search - / Pro-tip: enable find-as-you-type Learn current word lookups (*, #)

Slide 43

Slide 43 text

DRONE STRIKE The  quick  brown  fox  jumps  over  the  lazy  dog. destroy

Slide 44

Slide 44 text

The  quick  brown  fox  jumps  over  the  lazy  dog. DRONE STRIKE The  quick  brown  fox  jumps  over  the  lazy  dog. t t destroy

Slide 45

Slide 45 text

The  quick  brown  fox  jumps  over  the  lazy  dog. DRONE STRIKE The  quick  brown  fox  jumps  over  the  lazy  dog. t t destroy The  quick  brown  fox  jumps  over. d t .

Slide 46

Slide 46 text

TEXT OBJECTS Program code is full of blocks Easy matching: • a? - match the whole block • i? - match insides of the block Quotes: a” i” Round brackets: a) i) Braces: a} i} Tags: at it

Slide 47

Slide 47 text

TEXT OBJECTS 101 params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] }

Slide 48

Slide 48 text

params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] } TEXT OBJECTS 101 v i “ params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] }

Slide 49

Slide 49 text

params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] } TEXT OBJECTS 101

Slide 50

Slide 50 text

params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] } params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] } TEXT OBJECTS 101 i ]

Slide 51

Slide 51 text

params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] } TEXT OBJECTS 101

Slide 52

Slide 52 text

params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] } params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] } TEXT OBJECTS 101 a }

Slide 53

Slide 53 text

TEXT OBJECTS 101 same for Ruby blocks (with a plugin) ar - select the whole Ruby block ir - select inside Ruby block

Slide 54

Slide 54 text

params  =   params  =  {    users:  [  "Mal  Reynolds",  "Inara  Serra"  ] } TEXT OBJECTS 101 c a }

Slide 55

Slide 55 text

CHANGES Undo change - u Repeat change - . Shines when coupled with modal mode Think of your changes as steps, or brushstrokes

Slide 56

Slide 56 text

PRO TIPS Remap your ESC Disable your cursor keys Don’t use others’ configs in full Train yourself gradually But either dive in, or stay away

Slide 57

Slide 57 text

PERSONAL FAVORITES VIM running in pure text console mode Ctrl-Z to fall back into the shell Use external commands to process the data Coupled with tmux integration Quickly launch separate tasks (e.g. rspec) in tmux window

Slide 58

Slide 58 text

LOVE YOUR EDITOR