Slide 1

Slide 1 text

Semi-Skimmed vim A practical path to text editing enlightenment Sam Whitehall 2017-02-15 The Oxford Mega Super Meetup Meetup

Slide 2

Slide 2 text

What is this talk? • vim is a 25-year old command line modal text editor • Based on vi (even older) • Let’s skim the surface of why you may want to invest time into learning it

Slide 3

Slide 3 text

Learn!? It’s a text editor • Has a reputation of being hard to learn • You can’t just start typing and see your code • Insert Mode vs Normal Mode • Normal mode is where the power lies • Often compared with another command-line editor, emacs • We won’t get into the “holy war”

Slide 4

Slide 4 text

Why would I learn it? Ubiquitous Likely to be available Stable Learn it now, and it won’t change much Lightweight Won’t die with large files Fast Code a lot faster than a GUI editor

Slide 5

Slide 5 text

“Flow” is the killer reason for me (more on this later)

Slide 6

Slide 6 text

How do I get started? The Hard Way Everything all at once Do things “right” right away How I started (and failed) a few times The Practical Way Step-by-step Don’t worry about doing things “right” How I eventually got going

Slide 7

Slide 7 text

Step 1: Survive • $ vim my_file • Normal mode: • :w to save, :q to quit • i to enter insert mode • u to undo • x to delete character • ESC to return to normal mode Congratulations! You’re now as productive as in a normal text editor (especially if you have mouse mode enabled).

Slide 8

Slide 8 text

Step 2: Get Comfortable Entering Insert Mode Moving Around a o w $ ^ enter insert mode after cursor enter insert mode on line below cursor first character start of next word final character Examples: These may seem like trivial gains, but they add up over time. Especially in terms of focus. You’re telling your editor what you want it to do (reach the end of the line), not how you want to do it (pressing “right” 12 times).

Slide 9

Slide 9 text

(aside) • Learning vim is not a case of memorising loads of arbitrary shortcuts • It’s a grammar: modifiers, verbs & nouns → flow! • Most have mnemonics • d → delete, c → change (i.e. delete, then insert mode) http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118

Slide 10

Slide 10 text

dt: di( d$ delete to end of line ($) delete to the next : delete inside ()

Slide 11

Slide 11 text

ALL THE PIECES MAKE SENSE

Slide 12

Slide 12 text

Step 3: Expand Comfort Zone • Learn one noun/verb every day (/relevant time unit) • Stay in normal mode as often as possible (hit ESC a lot) • Make your own cheat sheet • Exponential power from combining these actions

Slide 13

Slide 13 text

• You can also use hjkl for cursor movement • This is weird at first, but requires less finger movement • You can edit your .vimrc to disable arrow keys • vim-adventures.com – great for practicing!

Slide 14

Slide 14 text

Step 4: Mastery visual mode blocks completions

Slide 15

Slide 15 text

• Customising your ~/.vimrc • Beginners’ .vimrc • github.com/samwhitehall/.vimrc • Start to customise your own!

Slide 16

Slide 16 text

Plugins • use Pathogen as a package manager NERDTree fugitive

Slide 17

Slide 17 text

You’ll be fine • Try it a little bit at a time, don’t be overwhelmed! • Thousands of people have learned it before, so can you!

Slide 18

Slide 18 text

Thanks! @sgwhall Ask me your vim questions, no question too simple!