Slide 1

Slide 1 text

Vim the final text editor you need to learn eddie@NISRA, fju

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Current Status 80% iOS app, 20% Ruby/Rails

Slide 4

Slide 4 text

Scenario

Slide 5

Slide 5 text

I'm looking for a text editor..

Slide 6

Slide 6 text

1. launch quickly 2. easy to navigate between files 3. and pretty syntax highlight

Slide 7

Slide 7 text

What's Vim?

Slide 8

Slide 8 text

it may look a little old-fashioned

Slide 9

Slide 9 text

but it can also be modern : )

Slide 10

Slide 10 text

So, Why Vim?

Slide 11

Slide 11 text

Keyboard-driven

Slide 12

Slide 12 text

Keyboard is King!

Slide 13

Slide 13 text

and, Why not Vim?

Slide 14

Slide 14 text

tonight, we have 2 Goals..

Slide 15

Slide 15 text

no Mouse

Slide 16

Slide 16 text

no Arrow keys

Slide 17

Slide 17 text

How to Vim?

Slide 18

Slide 18 text

Practice: Install Vim in your machine. http://www.vim.org/download.php

Slide 19

Slide 19 text

.vimrc

Slide 20

Slide 20 text

if you want to use my .vimrc 1. clone from my Github repo 2. cd to cloned repo and execute install script 3. make symbolic link for vim 4. done!

Slide 21

Slide 21 text

https://github.com/kaochenlong/eddie-vim

Slide 22

Slide 22 text

Modes normal, visual, and edit mode

Slide 23

Slide 23 text

Modes Switch: 1. in normal mode, i or a or o to enter insert mode(i = insert, a = append, o = newline) 2. in insert mode, ESC or Ctrl+[ to enter normal mode 3. in normal mode, hit v or V to enter visual mode 4. in visual mode, hit ESC or Ctrl+[ to normal mode

Slide 24

Slide 24 text

ESC or Ctrl + [

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Practice: launch Vim and switch between normal, visual, and edit mode.

Slide 27

Slide 27 text

Basic

Slide 28

Slide 28 text

✓:w write to file. ✓:q exit Vim. ✓:tabe create a new tab. ✓gt to switch to next tab, gT to previous tab. (I map gt and gT to F7 and F8 in my vimrc) ✓:new to create a horizontal split window, :vnew or :vs to create a vertical split window.

Slide 29

Slide 29 text

✓vi -o a.rb b.rb to open those two files at the same time with horizontal split window. ✓vi -O a.rb b.rb same as above, but in vertical split window. ✓vi -p a.rb b.rb to open files with tabs. ✓vi http://www.eddie.com.tw will read the source content into vim directly.

Slide 30

Slide 30 text

Practice: 1. quit Vim, and launch Vim, quite Vim, and launch Vim .. x N 2. open a file with Vim, exit, then open it again, then exit .. x N

Slide 31

Slide 31 text

Vim Text Objects

Slide 32

Slide 32 text

d 3 w = delete 3 words

Slide 33

Slide 33 text

Word: 1. aw - a word 2. iw - inner word

Slide 34

Slide 34 text

Practice: 1. select a word, deselect, and select another word, and deselect.. x N 2. select a word, delete it, select another word, and delete.. X N

Slide 35

Slide 35 text

Sentence: 1. as - a sentence 2. is - inner sentence

Slide 36

Slide 36 text

Practice: 1. select a sentence, deselect, and select another sentence, and deselect.. x N 2. select a sentence, delete it, select another sentence, and delete.. X N

Slide 37

Slide 37 text

Paragraph: 1. ap - a paragraph 2. ip - inner paragraph

Slide 38

Slide 38 text

Practice: 1. select a paragraph, deselect, and select another paragraph, and deselect.. x N 2. select a paragraph, delete it, select another paragraph, and delete.. X N

Slide 39

Slide 39 text

Movement :h movement

Slide 40

Slide 40 text

move cursor with h, j, k and l disable arrow keys if possible

Slide 41

Slide 41 text

✓w or W to move cursor forward by a word, and b or B is backward. ✓0 to back to the begin of the line, and $ is jump to the end. ✓fx will stop the cursor at the next "x" character in current line, and F is search backward.

Slide 42

Slide 42 text

✓} will move cursor to next section, { move to last section. ✓vit will visually select content between the tag, while vat will even including the tag. ✓vi" will visually select content between current double quotes. ✓viw will select the current word.

Slide 43

Slide 43 text

✓gg will move the cursor to the top of the current file, and G will jump to bottom. ✓zz, zb, zt ✓/ search, n can jump to next matched result, and N will jump to last one. ✓* search the word on cursor.

Slide 44

Slide 44 text

Practice: try to move cursor with hjkl keys, not arrow keys.

Slide 45

Slide 45 text

Buffers :ls, :bd, :b3, :b filename, :tab ba

Slide 46

Slide 46 text

Practice: try to open several files, and switch between them with buffer commands.

Slide 47

Slide 47 text

Folding :h folds

Slide 48

Slide 48 text

Basic: - zf to fold selected lines - zd to un-fold selected lines

Slide 49

Slide 49 text

Practice: fold several lines, and unfold them .. x N

Slide 50

Slide 50 text

Editing

Slide 51

Slide 51 text

✓D to clear all content of current line after the cursor. ✓C like D, but enter insert mode. dG will clear all content after the cursor, dgg will clear all content before the cursor. ✓x remove a character. ✓. to repeat last action. ✓dd to delete whole line, 3dd to delete 3 lines.

Slide 52

Slide 52 text

✓yy yank the whole line of the cursor. ✓3yy yank 3 lines. ✓p paste content from register, 3p paster content from register for 3 times. ✓= re-format, gg=G re-format whole file.

Slide 53

Slide 53 text

✓dw, diw to delete the word in the cursor. ✓cw, ciw same as above, but enter insert mode. r to replace current character. ✓J to concatenate current line with next line, 3J will concatenate next 3 lines. ✓> to add indentation, < to remove indentation.

Slide 54

Slide 54 text

Plugins

Slide 55

Slide 55 text

Pathogen nice plugin manager https://github.com/tpope/vim-pathogen

Slide 56

Slide 56 text

NERDTree A tree explorer https://github.com/scrooloose/nerdtree

Slide 57

Slide 57 text

SnipMate code snippets plugin, inspired by TextMate https://github.com/msanders/snipmate.vim

Slide 58

Slide 58 text

ctrlp Fuzzy file, buffer, mru, tag, etc finder https://github.com/kien/ctrlp.vim

Slide 59

Slide 59 text

surround.vim quoting/parenthesizing made simple https://github.com/tpope/vim-surround

Slide 60

Slide 60 text

vim-multiple-cursors Sublime Text style multiple selections for Vim https://github.com/terryma/vim-multiple-cursors

Slide 61

Slide 61 text

powerline the ultimate vim statusline utility https://github.com/Lokaltog/vim-powerline

Slide 62

Slide 62 text

rails.vim Ruby on Rails power tools https://github.com/tpope/vim-rails

Slide 63

Slide 63 text

fugitive a git wrapper for vim https://github.com/tpope/vim-fugitive

Slide 64

Slide 64 text

vimwiki personal wiki for vim https://github.com/vim-scripts/vimwiki

Slide 65

Slide 65 text

ragtag https://github.com/tpope/vim-ragtag

Slide 66

Slide 66 text

Practicing!

Slide 67

Slide 67 text

References

Slide 68

Slide 68 text

http://blog.eddie.com.tw/screencasts/

Slide 69

Slide 69 text

and more practice.. : )

Slide 70

Slide 70 text

Tips

Slide 71

Slide 71 text

in terminal: 1. ctrl + z to stash vim, and type fg to bring it back. 2. ctrl + w to delete a word, ctrl + u to delete a whole line, both work in terminal and vim edit mode. 3. ctrl + r to find history commands fuzzily.