SlideShare a Scribd company logo
Mission Vim-Possible
     by Sam Gottfried
History of Vim
"In the beginning, there was ed. And ed begat
ex; and ex begat vi; and vi begat vim."
What is Vim?
● Vim is a highly customizable, highly efficient
  text editor


● Vim has several modes
   ○   Normal
   ○   Insert
   ○   Visual
   ○   Ex mode
Normal Mode
Normal Mode is the default mode in Vim.

You should spend most of your time in normal
mode.
Text Objects
a = a/an
i = inside

aw -> a word
aW -> a WORD

as -> a sentence

ap -> a paragraph
More Text Objects
a( -> a pair of parenthesis

a{ -> a pair of {braces}

a[ -> a pair of [brackets]

a< -> a pair of <angle brackets>

at -> a pair of XML tags
More Text Objects
a" -> a pair of "quotes"
a' -> a pair of 'quotes'

Examples:
da" -> delete a pair of quotes
ci" -> change everything between the quotes
yap -> yank a paragraph
Motions
words vs WORDS
def foo(a,b)

word: [def][foo][(][a][,][b][)]
WORD: [def][foo(a,b)]

w -> next word                    e -> end of word
W -> next WORD                    E -> end of WORD

b-> beginning of current word
B -> beginning of current WORD
More Motions
f -> find a character
F -> find a character (reverse)

t -> go to just before a character
T -> go to just after a character
(reverse)

; -> next match (for f/F/t/T)
, -> previous match (for f/F/t/T)
More Motions
/ -> search forward
? -> search backwards
n -> next match (current direction)
N -> previous match (current direction)

* -> search for word under the cursor
# -> search backwards for word under the
cursor
Operator
y -> yank
d -> delete
c -> change

p -> paste (after)
P -> paste (before)

Operator + motion = action
dw -> delete to the next word
Line-wise operations
dd -> delete a line
cc -> change a line
yy -> yank a line (copy)

>> -> shift right
<< -> shift left
== -> auto indent
Counts
Most motions take a count
3w -> move ahead 3 words
5s -> move ahead 3 sentences

These can be combined with actions
3dw -> delete a word 3 times (or d3w)
5dd -> delete 5 lines
2yy -> yank 2 lines
Undo/Redo
Act, Repeat, Reverse

. -> repeat a change
u -> undo a change

- Chunk your Undos
- Compose repeatable changes
- Don't count if you can repeat
Insert Mode
Entering Insert Mode
i -> insert to the left of the cursor
a -> insert to the right of the cursor (append)
c -> change (usually combined with a motion)

I -> Insert at the beginning of the current line
A -> Append to the end of the current line
cc -> change the current line
Visual Mode
v -> character-wise Visual mode
V -> line-wise Visual mode
<C-v> -> block-wise Visual mode
gv -> re-selects last visual selection

You can switch between these without going
into normal mode
Ex mode
: -> enter Ex command
Q -> enter Ex mode (:visual to get out)

:[range]d[elete] ->
     deletes specified lines
:[range]y[ank] ->
     yanks specified lines
:[line]put ->
     puts the yanked lines under the current line
Ex Mode Examples
:5 -> go to line 5
:5p -> print line 5
:$ -> go to last line
:2,5p -> print lines 2-5
:% -> the whole document
:. -> the current line
Registers
Use registers with yanks and deletes
Increase your clipboard size to 27!

"[register][count]action text object

example:
"ayiw => Yank current word into register a
"ap => Paste from register a
Macros
Record a sequence of changes and then play
them back

q{register} -> record a macro into a register
qa -> start recording a macro into register a

Press q again to stop the recording
@{register} -> playback the macro in {register}
Linewise Motions
0 -> go to beginning of a line
^ -> first non-whitespace character of a line

$ -> end of line
Macro Tips
Macros can be done in series

Macros can also be done in parallel

Macros are useful with counts (Dot command
doesn't accept counts)
Plugins
Tim Pope's Pathogen - Plugin Manager
github.com/tpope/vim-pathogen

Vim-Rails
github.com/tpope/vim-rails

Ruby-Test
github.com/janx/vim-rubytest
More Plugins
NERDTree -> File tree explorer
github.com/scrooloose/nerdtree

Fugitive -> Git from within Vim
github.com/tpope/vim-fugitive

Greplace -> Project search and replace
github.com/skwp/greplace.vim
More Plugins
Ack.vim -> Search project with Ack
github.com/mileszs/ack.vim

Ultisnips -> Textmate-like snippets
github.com/SirVer/ultisnips

Ctrlp -> Fuzzy find files
github.com/kien/ctrlp.vim
More Plugins
Supertab -> Easier autocomplete
github.com/ervandew/supertab
Vimrc
Configuration for Vim
Resources
vimtutor

:help <topic>

Practical Vim (from pragmatic bookshelf)

Vimcasts (http://vimcasts.org)
Sam Gottfried
sgottfried@cyrusinnovation.com

github.com/sgottfried

Twitter: @sam_gottfried
Mission vim possible

More Related Content

What's hot

2.6 transformations
2.6 transformations2.6 transformations
2.6 transformationshisema01
 
The Ring programming language version 1.3 book - Part 14 of 88
The Ring programming language version 1.3 book - Part 14 of 88The Ring programming language version 1.3 book - Part 14 of 88
The Ring programming language version 1.3 book - Part 14 of 88
Mahmoud Samir Fayed
 
Currying in Swift
Currying in SwiftCurrying in Swift
Currying in Swift
Maxim Zaks
 
Transducers
TransducersTransducers
Transducers
Aleš Roubíček
 
The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185
Mahmoud Samir Fayed
 
12.string and pointer
12.string and pointer12.string and pointer
12.string and pointer
Gem WeBlog
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180
Mahmoud Samir Fayed
 
2.5 function transformations
2.5 function transformations2.5 function transformations
2.5 function transformationshisema01
 
The Ring programming language version 1.5.3 book - Part 23 of 184
The Ring programming language version 1.5.3 book - Part 23 of 184The Ring programming language version 1.5.3 book - Part 23 of 184
The Ring programming language version 1.5.3 book - Part 23 of 184
Mahmoud Samir Fayed
 
Python programing
Python programingPython programing
Python programing
BHAVYA DOSHI
 
1 arrays and sorting
1 arrays and sorting1 arrays and sorting
1 arrays and sortingnotshoaib
 
pycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslatepycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslate
Renyuan Lyu
 
Derivatives Lesson Oct 14
Derivatives Lesson  Oct 14Derivatives Lesson  Oct 14
Derivatives Lesson Oct 14ingroy
 
The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.10 book - Part 31 of 212The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.10 book - Part 31 of 212
Mahmoud Samir Fayed
 
하스켈 프로그래밍 입문 4
하스켈 프로그래밍 입문 4하스켈 프로그래밍 입문 4
하스켈 프로그래밍 입문 4
Kwang Yul Seo
 
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Philip Schwarz
 
バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向
弘毅 露崎
 

What's hot (20)

2.6 transformations
2.6 transformations2.6 transformations
2.6 transformations
 
The Ring programming language version 1.3 book - Part 14 of 88
The Ring programming language version 1.3 book - Part 14 of 88The Ring programming language version 1.3 book - Part 14 of 88
The Ring programming language version 1.3 book - Part 14 of 88
 
Currying in Swift
Currying in SwiftCurrying in Swift
Currying in Swift
 
Transducers
TransducersTransducers
Transducers
 
The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185
 
12.string and pointer
12.string and pointer12.string and pointer
12.string and pointer
 
Array&pointer
Array&pointerArray&pointer
Array&pointer
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180
 
2.5 function transformations
2.5 function transformations2.5 function transformations
2.5 function transformations
 
The Ring programming language version 1.5.3 book - Part 23 of 184
The Ring programming language version 1.5.3 book - Part 23 of 184The Ring programming language version 1.5.3 book - Part 23 of 184
The Ring programming language version 1.5.3 book - Part 23 of 184
 
Python programing
Python programingPython programing
Python programing
 
1 arrays and sorting
1 arrays and sorting1 arrays and sorting
1 arrays and sorting
 
Oracle SQL
Oracle SQLOracle SQL
Oracle SQL
 
pycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslatepycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslate
 
Derivatives Lesson Oct 14
Derivatives Lesson  Oct 14Derivatives Lesson  Oct 14
Derivatives Lesson Oct 14
 
The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.10 book - Part 31 of 212The Ring programming language version 1.10 book - Part 31 of 212
The Ring programming language version 1.10 book - Part 31 of 212
 
하스켈 프로그래밍 입문 4
하스켈 프로그래밍 입문 4하스켈 프로그래밍 입문 4
하스켈 프로그래밍 입문 4
 
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
 
バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向バイオインフォ分野におけるtidyなデータ解析の最新動向
バイオインフォ分野におけるtidyなデータ解析の最新動向
 
Strings1
Strings1Strings1
Strings1
 

Viewers also liked

Partes del impress 4
Partes del impress 4Partes del impress 4
Partes del impress 4fernandiitho
 
Teaching strategies
Teaching strategiesTeaching strategies
Teaching strategiestlfinch2431
 
Partes del impress
Partes del impressPartes del impress
Partes del impressfernandiitho
 
Shareleksveckan - Kollaborativ ekonomi
Shareleksveckan - Kollaborativ ekonomiShareleksveckan - Kollaborativ ekonomi
Shareleksveckan - Kollaborativ ekonomi
Emma Öhrwall
 
Buku panduan-ujian-tulis-keterampilan-snmptn2011
Buku panduan-ujian-tulis-keterampilan-snmptn2011Buku panduan-ujian-tulis-keterampilan-snmptn2011
Buku panduan-ujian-tulis-keterampilan-snmptn2011Budi Arto
 
Introduction to machine learning
Introduction to machine learningIntroduction to machine learning
Introduction to machine learning
Ganesh Satpute
 
51998292 teori-perhitungan-bearing
51998292 teori-perhitungan-bearing51998292 teori-perhitungan-bearing
51998292 teori-perhitungan-bearing
oto09
 
Mengenalpowerpoint2007
Mengenalpowerpoint2007Mengenalpowerpoint2007
Mengenalpowerpoint2007Budi Arto
 
Collections
CollectionsCollections
Collections
bsurya1989
 
Tutorial pembuatan-media-pembelajaran-interaktif-dengan-powerpoin tx
Tutorial pembuatan-media-pembelajaran-interaktif-dengan-powerpoin txTutorial pembuatan-media-pembelajaran-interaktif-dengan-powerpoin tx
Tutorial pembuatan-media-pembelajaran-interaktif-dengan-powerpoin txBudi Arto
 
Cancer of the skin (malignant melanoma)
Cancer of the skin (malignant melanoma)Cancer of the skin (malignant melanoma)
Cancer of the skin (malignant melanoma)
Mary Grace Polancos
 
Buku panduan-praktikum-powerpoint 2007
Buku panduan-praktikum-powerpoint 2007Buku panduan-praktikum-powerpoint 2007
Buku panduan-praktikum-powerpoint 2007Budi Arto
 

Viewers also liked (18)

Leds
LedsLeds
Leds
 
Partes del impress 4
Partes del impress 4Partes del impress 4
Partes del impress 4
 
Noticia leds
Noticia ledsNoticia leds
Noticia leds
 
Leds
LedsLeds
Leds
 
Teaching strategies
Teaching strategiesTeaching strategies
Teaching strategies
 
Noticia leds
Noticia ledsNoticia leds
Noticia leds
 
Partes del impress
Partes del impressPartes del impress
Partes del impress
 
Reunió pedagògica p3
Reunió pedagògica p3Reunió pedagògica p3
Reunió pedagògica p3
 
Shareleksveckan - Kollaborativ ekonomi
Shareleksveckan - Kollaborativ ekonomiShareleksveckan - Kollaborativ ekonomi
Shareleksveckan - Kollaborativ ekonomi
 
Buku panduan-ujian-tulis-keterampilan-snmptn2011
Buku panduan-ujian-tulis-keterampilan-snmptn2011Buku panduan-ujian-tulis-keterampilan-snmptn2011
Buku panduan-ujian-tulis-keterampilan-snmptn2011
 
Introduction to machine learning
Introduction to machine learningIntroduction to machine learning
Introduction to machine learning
 
Clustering
ClusteringClustering
Clustering
 
51998292 teori-perhitungan-bearing
51998292 teori-perhitungan-bearing51998292 teori-perhitungan-bearing
51998292 teori-perhitungan-bearing
 
Mengenalpowerpoint2007
Mengenalpowerpoint2007Mengenalpowerpoint2007
Mengenalpowerpoint2007
 
Collections
CollectionsCollections
Collections
 
Tutorial pembuatan-media-pembelajaran-interaktif-dengan-powerpoin tx
Tutorial pembuatan-media-pembelajaran-interaktif-dengan-powerpoin txTutorial pembuatan-media-pembelajaran-interaktif-dengan-powerpoin tx
Tutorial pembuatan-media-pembelajaran-interaktif-dengan-powerpoin tx
 
Cancer of the skin (malignant melanoma)
Cancer of the skin (malignant melanoma)Cancer of the skin (malignant melanoma)
Cancer of the skin (malignant melanoma)
 
Buku panduan-praktikum-powerpoint 2007
Buku panduan-praktikum-powerpoint 2007Buku panduan-praktikum-powerpoint 2007
Buku panduan-praktikum-powerpoint 2007
 

Similar to Mission vim possible

Vim Cheat Sheet.pdf
Vim Cheat Sheet.pdfVim Cheat Sheet.pdf
Vim Cheat Sheet.pdf
AdelinaBronda1
 
VI Editor
VI EditorVI Editor
VI Editor
Nishant Munjal
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foobrian_dailey
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
Shay Cohen
 
Python language data types
Python language data typesPython language data types
Python language data types
James Wong
 
Python language data types
Python language data typesPython language data types
Python language data types
Harry Potter
 
Python language data types
Python language data typesPython language data types
Python language data types
Hoang Nguyen
 
Python language data types
Python language data typesPython language data types
Python language data types
Young Alista
 
Python language data types
Python language data typesPython language data types
Python language data types
Luis Goldster
 
Python language data types
Python language data typesPython language data types
Python language data types
Tony Nguyen
 
Python language data types
Python language data typesPython language data types
Python language data types
Fraboni Ec
 
R Programming: Export/Output Data In R
R Programming: Export/Output Data In RR Programming: Export/Output Data In R
R Programming: Export/Output Data In R
Rsquared Academy
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
Farrukh Salman
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
Kopi Maheswaran
 
Introduction to Vim, the text editor
Introduction to Vim, the text editorIntroduction to Vim, the text editor
Introduction to Vim, the text editor
Vysakh Sreenivasan
 
vim-cheatsheet.pdf
vim-cheatsheet.pdfvim-cheatsheet.pdf
vim-cheatsheet.pdf
AnkitPangasa1
 

Similar to Mission vim possible (20)

Vim Cheat Sheet.pdf
Vim Cheat Sheet.pdfVim Cheat Sheet.pdf
Vim Cheat Sheet.pdf
 
Vim and Python
Vim and PythonVim and Python
Vim and Python
 
Python 1
Python 1Python 1
Python 1
 
VI Editor
VI EditorVI Editor
VI Editor
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
 
Vim basic
Vim basicVim basic
Vim basic
 
DevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung FooDevChatt 2010 - *nix Cmd Line Kung Foo
DevChatt 2010 - *nix Cmd Line Kung Foo
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
Python language data types
Python language data typesPython language data types
Python language data types
 
R Programming: Export/Output Data In R
R Programming: Export/Output Data In RR Programming: Export/Output Data In R
R Programming: Export/Output Data In R
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
Introduction to Vim, the text editor
Introduction to Vim, the text editorIntroduction to Vim, the text editor
Introduction to Vim, the text editor
 
vim-cheatsheet.pdf
vim-cheatsheet.pdfvim-cheatsheet.pdf
vim-cheatsheet.pdf
 

Mission vim possible

  • 1. Mission Vim-Possible by Sam Gottfried
  • 2. History of Vim "In the beginning, there was ed. And ed begat ex; and ex begat vi; and vi begat vim."
  • 3. What is Vim? ● Vim is a highly customizable, highly efficient text editor ● Vim has several modes ○ Normal ○ Insert ○ Visual ○ Ex mode
  • 4. Normal Mode Normal Mode is the default mode in Vim. You should spend most of your time in normal mode.
  • 5. Text Objects a = a/an i = inside aw -> a word aW -> a WORD as -> a sentence ap -> a paragraph
  • 6. More Text Objects a( -> a pair of parenthesis a{ -> a pair of {braces} a[ -> a pair of [brackets] a< -> a pair of <angle brackets> at -> a pair of XML tags
  • 7. More Text Objects a" -> a pair of "quotes" a' -> a pair of 'quotes' Examples: da" -> delete a pair of quotes ci" -> change everything between the quotes yap -> yank a paragraph
  • 8. Motions words vs WORDS def foo(a,b) word: [def][foo][(][a][,][b][)] WORD: [def][foo(a,b)] w -> next word e -> end of word W -> next WORD E -> end of WORD b-> beginning of current word B -> beginning of current WORD
  • 9. More Motions f -> find a character F -> find a character (reverse) t -> go to just before a character T -> go to just after a character (reverse) ; -> next match (for f/F/t/T) , -> previous match (for f/F/t/T)
  • 10. More Motions / -> search forward ? -> search backwards n -> next match (current direction) N -> previous match (current direction) * -> search for word under the cursor # -> search backwards for word under the cursor
  • 11. Operator y -> yank d -> delete c -> change p -> paste (after) P -> paste (before) Operator + motion = action dw -> delete to the next word
  • 12. Line-wise operations dd -> delete a line cc -> change a line yy -> yank a line (copy) >> -> shift right << -> shift left == -> auto indent
  • 13. Counts Most motions take a count 3w -> move ahead 3 words 5s -> move ahead 3 sentences These can be combined with actions 3dw -> delete a word 3 times (or d3w) 5dd -> delete 5 lines 2yy -> yank 2 lines
  • 14. Undo/Redo Act, Repeat, Reverse . -> repeat a change u -> undo a change - Chunk your Undos - Compose repeatable changes - Don't count if you can repeat
  • 15. Insert Mode Entering Insert Mode i -> insert to the left of the cursor a -> insert to the right of the cursor (append) c -> change (usually combined with a motion) I -> Insert at the beginning of the current line A -> Append to the end of the current line cc -> change the current line
  • 16. Visual Mode v -> character-wise Visual mode V -> line-wise Visual mode <C-v> -> block-wise Visual mode gv -> re-selects last visual selection You can switch between these without going into normal mode
  • 17. Ex mode : -> enter Ex command Q -> enter Ex mode (:visual to get out) :[range]d[elete] -> deletes specified lines :[range]y[ank] -> yanks specified lines :[line]put -> puts the yanked lines under the current line
  • 18. Ex Mode Examples :5 -> go to line 5 :5p -> print line 5 :$ -> go to last line :2,5p -> print lines 2-5 :% -> the whole document :. -> the current line
  • 19. Registers Use registers with yanks and deletes Increase your clipboard size to 27! "[register][count]action text object example: "ayiw => Yank current word into register a "ap => Paste from register a
  • 20. Macros Record a sequence of changes and then play them back q{register} -> record a macro into a register qa -> start recording a macro into register a Press q again to stop the recording @{register} -> playback the macro in {register}
  • 21. Linewise Motions 0 -> go to beginning of a line ^ -> first non-whitespace character of a line $ -> end of line
  • 22. Macro Tips Macros can be done in series Macros can also be done in parallel Macros are useful with counts (Dot command doesn't accept counts)
  • 23. Plugins Tim Pope's Pathogen - Plugin Manager github.com/tpope/vim-pathogen Vim-Rails github.com/tpope/vim-rails Ruby-Test github.com/janx/vim-rubytest
  • 24. More Plugins NERDTree -> File tree explorer github.com/scrooloose/nerdtree Fugitive -> Git from within Vim github.com/tpope/vim-fugitive Greplace -> Project search and replace github.com/skwp/greplace.vim
  • 25. More Plugins Ack.vim -> Search project with Ack github.com/mileszs/ack.vim Ultisnips -> Textmate-like snippets github.com/SirVer/ultisnips Ctrlp -> Fuzzy find files github.com/kien/ctrlp.vim
  • 26. More Plugins Supertab -> Easier autocomplete github.com/ervandew/supertab
  • 28. Resources vimtutor :help <topic> Practical Vim (from pragmatic bookshelf) Vimcasts (http://vimcasts.org)