SlideShare ist ein Scribd-Unternehmen logo
1 von 18
Downloaden Sie, um offline zu lesen
Vim
By Parker Wightman
Vim - Why
• Vi was pretty terrible.Vim is vi-improved.
• Purpose:
   • Efficient text editing
   • Not typing faster
• Nearly every linux/unix install comes
  with vi out of the box. Lots of mileage in
  many domains.
Motivation

• You may have heard that “fast/efficient
  typing speed doesn’t make you a good
  developer.”
• This is true, but also misleading.
• It doesn’t make you a good developer, but
  it does make you a better developer.
Motivation
 • No one has deep thoughts while they type.


Thinking   Typing    Thinking    Typing
Motivation
 • The goal is to shorten time spent typing to
    maximize thinking.




Thinking Typing Thinking Typing
Motivation
      • This allows you to think more in the
         same amount of time




Thinking Typing Thinking Typing Thinking Typing Thinking Typing
Vim
•   Modal Editor - Keys on keyboard do different
    things in different modes.
    •   Normal Mode - Keys are used to move
        around the text.
    •   Insert Mode - Keys used to type as normal.
    •   Visual Mode - Moving the cursor around
        highlights text (e.g. for cut/copy/paste)
    •   Command Mode - Send commands to
        Vim, such as changing the font, saving the file,
        etc.
Normal Mode - Motions
 •   Motions allow you to move around the document.
 •   h, j, k, l map to left, down, up, and right respectively.
 •   w - move one word forward
 •   b - move one word backward
 •   e - move to end of word
 •   ^ and $ move to beginning/end of line (taken from
     regular expression syntax)
Normal Mode - Motions
       (cont.)

 • Combine numbers with motions.
    • 10j - move 10 lines down
    • 4w - move 4 words forward
Normal Mode - Advanced Motions

  • f<letter> - move cursor on top of first
    encountered <letter> in current line.
  • F<letter> - same as f, but backwards
  • t<letter> - move cursor behind first
    encountered <letter> in current line
  • T<letter> - same as t, but backward
  • / - Search (I prefer this)
Normal Mode - Verbs
•   Verbs must (usually) be mixed with motions (nouns)
•   x - delete forward (no motion required)
•   d - delete (cut)
      •   dw - delete one word forward (include whitespace)
      •   de - delete to end of word (don’t include whitespace)
      •   d$ - delete from where my cursor is to the end of
          the line
      •   dd - delete entire line
      •   d4w - delete 4 words
•   c - change (same as delete but puts you in insert mode
    after)
•   y - yank (copy)
Normal Mode - Sentences
 • Combine everything for superpowers
    • i (inside) a (around)
    • syntax - <verb><i/a><motion>
    • ci” - delete inside quotes
    • ci{ - delete inside { ... }
    • ciw - change inside current word
Insert Mode
•   Text editing as normal
•   Pressing i from normal mode enters insert mode
•   esc exits insert mode back into normal mode
•   (You can also use ctrl+[, which I prefer.You can also
    make your own keybinding.)
•   shift+i - enter insert mode just before first character
    of line
•   shift+a - enter insert mode just after last character
    in line
Visual Mode
•   v - enter visual mode. All motions will now
    move the highlight.
•   shift-v - highlight entire line
•   ctrl-v - highlight vertically (mind asplode)
•   All motions still work, w to jump words, $ to
    jump to the end of the line, etc.
•   All verbs still work. Highlight text, press d to
    delete, c to change, etc.
Command Mode
•   Command mode allows you to send commands to vim
•   Typing a colon (:) from normal mode puts you in
    command mode
•   Examples:
    •   :w - Save the current file
    •   :e /path/to/file - edit a file
    •   :q - quit vim
    •   :q! - quit vim without saving (vim yells at you if you
        try to quit without saving, this shuts vim up.)
Customizable

• Lots of plugins, most suck.
• NERDtree for tree navigation of files
• taglist also nice.
• Many, many others.
Customizable
• Vim uses VimScript/VimL for custom
  scripting and it SUCKS.

                 Percentage of angry
                  issues/commits on
                 GitHub by language
Using Vim without
          using Vim
•   Some editors support “vim mode”. Sublime
    Text,Visual Studio plugin, Xcode plugin, Qt
    editor-thing, emacs.
•   “vim mode” will emulate basic keybindings,
    but cannot run plugins written in VimScript
    (which may be a good thing)
•   If I did not feel tied to some Vim plugins, I
    would personally use Sublime Text with vim
    mode enabled.

Weitere ähnliche Inhalte

Ähnlich wie Vim Basics

lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptxpoonam256394
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editorShay Cohen
 
Effective text editing with vim
Effective text editing with vimEffective text editing with vim
Effective text editing with vimxprayc
 
Presentacion vim
Presentacion vimPresentacion vim
Presentacion vimIcalia Labs
 
VI editor in unix
VI editor in unix VI editor in unix
VI editor in unix Ahmed Fayyaz
 
Introduction to Vim
Introduction to VimIntroduction to Vim
Introduction to VimBrandon Liu
 
Linux text editors Vim nano
Linux text editors Vim nano Linux text editors Vim nano
Linux text editors Vim nano Md Meherab Hossen
 
vim brownbag - Richard forth
vim brownbag - Richard forthvim brownbag - Richard forth
vim brownbag - Richard forthEdwardElric59
 
Web Technology Assignment.pptx
Web Technology Assignment.pptxWeb Technology Assignment.pptx
Web Technology Assignment.pptxJanviDubey2
 
IntroPython-Week02-StringsIteration.pptx
IntroPython-Week02-StringsIteration.pptxIntroPython-Week02-StringsIteration.pptx
IntroPython-Week02-StringsIteration.pptxchrisdy932
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talkReuven Lerner
 
40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.xHo Kim
 
Getting the Most from Xamarin Studio - Michael Hutchinson
Getting the Most from Xamarin Studio - Michael HutchinsonGetting the Most from Xamarin Studio - Michael Hutchinson
Getting the Most from Xamarin Studio - Michael HutchinsonXamarin
 

Ähnlich wie Vim Basics (20)

lectuer 21-22.pptx
lectuer 21-22.pptxlectuer 21-22.pptx
lectuer 21-22.pptx
 
Tweakers Anonymous
Tweakers AnonymousTweakers Anonymous
Tweakers Anonymous
 
07 vi text_editor
07 vi text_editor07 vi text_editor
07 vi text_editor
 
Effective text editing with vim
Effective text editing with vimEffective text editing with vim
Effective text editing with vim
 
Presentacion vim
Presentacion vimPresentacion vim
Presentacion vim
 
VI editor in unix
VI editor in unix VI editor in unix
VI editor in unix
 
What is Vim?
What is Vim?What is Vim?
What is Vim?
 
Tweakers Anonymous
Tweakers AnonymousTweakers Anonymous
Tweakers Anonymous
 
Introduction to Vim
Introduction to VimIntroduction to Vim
Introduction to Vim
 
Linux text editors Vim nano
Linux text editors Vim nano Linux text editors Vim nano
Linux text editors Vim nano
 
Linux text editors
Linux text editorsLinux text editors
Linux text editors
 
vim brownbag - Richard forth
vim brownbag - Richard forthvim brownbag - Richard forth
vim brownbag - Richard forth
 
Delphi L04 Controls P2
Delphi L04 Controls P2Delphi L04 Controls P2
Delphi L04 Controls P2
 
Web Technology Assignment.pptx
Web Technology Assignment.pptxWeb Technology Assignment.pptx
Web Technology Assignment.pptx
 
Using vi
Using viUsing vi
Using vi
 
Vi Editor
Vi EditorVi Editor
Vi Editor
 
IntroPython-Week02-StringsIteration.pptx
IntroPython-Week02-StringsIteration.pptxIntroPython-Week02-StringsIteration.pptx
IntroPython-Week02-StringsIteration.pptx
 
Rails development environment talk
Rails development environment talkRails development environment talk
Rails development environment talk
 
40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x
 
Getting the Most from Xamarin Studio - Michael Hutchinson
Getting the Most from Xamarin Studio - Michael HutchinsonGetting the Most from Xamarin Studio - Michael Hutchinson
Getting the Most from Xamarin Studio - Michael Hutchinson
 

Vim Basics

  • 2. Vim - Why • Vi was pretty terrible.Vim is vi-improved. • Purpose: • Efficient text editing • Not typing faster • Nearly every linux/unix install comes with vi out of the box. Lots of mileage in many domains.
  • 3. Motivation • You may have heard that “fast/efficient typing speed doesn’t make you a good developer.” • This is true, but also misleading. • It doesn’t make you a good developer, but it does make you a better developer.
  • 4. Motivation • No one has deep thoughts while they type. Thinking Typing Thinking Typing
  • 5. Motivation • The goal is to shorten time spent typing to maximize thinking. Thinking Typing Thinking Typing
  • 6. Motivation • This allows you to think more in the same amount of time Thinking Typing Thinking Typing Thinking Typing Thinking Typing
  • 7. Vim • Modal Editor - Keys on keyboard do different things in different modes. • Normal Mode - Keys are used to move around the text. • Insert Mode - Keys used to type as normal. • Visual Mode - Moving the cursor around highlights text (e.g. for cut/copy/paste) • Command Mode - Send commands to Vim, such as changing the font, saving the file, etc.
  • 8. Normal Mode - Motions • Motions allow you to move around the document. • h, j, k, l map to left, down, up, and right respectively. • w - move one word forward • b - move one word backward • e - move to end of word • ^ and $ move to beginning/end of line (taken from regular expression syntax)
  • 9. Normal Mode - Motions (cont.) • Combine numbers with motions. • 10j - move 10 lines down • 4w - move 4 words forward
  • 10. Normal Mode - Advanced Motions • f<letter> - move cursor on top of first encountered <letter> in current line. • F<letter> - same as f, but backwards • t<letter> - move cursor behind first encountered <letter> in current line • T<letter> - same as t, but backward • / - Search (I prefer this)
  • 11. Normal Mode - Verbs • Verbs must (usually) be mixed with motions (nouns) • x - delete forward (no motion required) • d - delete (cut) • dw - delete one word forward (include whitespace) • de - delete to end of word (don’t include whitespace) • d$ - delete from where my cursor is to the end of the line • dd - delete entire line • d4w - delete 4 words • c - change (same as delete but puts you in insert mode after) • y - yank (copy)
  • 12. Normal Mode - Sentences • Combine everything for superpowers • i (inside) a (around) • syntax - <verb><i/a><motion> • ci” - delete inside quotes • ci{ - delete inside { ... } • ciw - change inside current word
  • 13. Insert Mode • Text editing as normal • Pressing i from normal mode enters insert mode • esc exits insert mode back into normal mode • (You can also use ctrl+[, which I prefer.You can also make your own keybinding.) • shift+i - enter insert mode just before first character of line • shift+a - enter insert mode just after last character in line
  • 14. Visual Mode • v - enter visual mode. All motions will now move the highlight. • shift-v - highlight entire line • ctrl-v - highlight vertically (mind asplode) • All motions still work, w to jump words, $ to jump to the end of the line, etc. • All verbs still work. Highlight text, press d to delete, c to change, etc.
  • 15. Command Mode • Command mode allows you to send commands to vim • Typing a colon (:) from normal mode puts you in command mode • Examples: • :w - Save the current file • :e /path/to/file - edit a file • :q - quit vim • :q! - quit vim without saving (vim yells at you if you try to quit without saving, this shuts vim up.)
  • 16. Customizable • Lots of plugins, most suck. • NERDtree for tree navigation of files • taglist also nice. • Many, many others.
  • 17. Customizable • Vim uses VimScript/VimL for custom scripting and it SUCKS. Percentage of angry issues/commits on GitHub by language
  • 18. Using Vim without using Vim • Some editors support “vim mode”. Sublime Text,Visual Studio plugin, Xcode plugin, Qt editor-thing, emacs. • “vim mode” will emulate basic keybindings, but cannot run plugins written in VimScript (which may be a good thing) • If I did not feel tied to some Vim plugins, I would personally use Sublime Text with vim mode enabled.