Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to VIM

Introduction to VIM

Introduction to one of the most versatile text editor on the linux system.

Zaki Shaheen

July 24, 2014
Tweet

More Decks by Zaki Shaheen

Other Decks in Programming

Transcript

  1. Agenda • History of vim • Why use vim? •

    Features • Resources we will use • Basic usage • Advanced usage • Question and answers
  2. History of vim • vi created by Bill Joy (co-founder

    Sun Microsystems) in 1976 for UNIX • Replacement of older editors in UNIX • Vim created by Bram Moolenaar (Google) in 1988
  3. Why use VIM? • A text editor available everywhere •

    Included with all linux distros • Faster editing - no need to take hands off the keyboard • By developers, for developers • Lots of features • OpenSource, Free
  4. Features • syntax highlighting • highly customisable • advanced searching

    • auto indentation • split windows • “typing at the speed of thought” • etc.
  5. Learning vim Easy way vimtutor Hard way throw away all

    other editors for 2 weeks and use the cheat-sheet
  6. Open and quit • ‘vim myfile.php’ • :q (quit file)

    • :q! or ZZ (quit without saving) • :wq or ZQ (quit with saving) • :e myfile.php (edit myfile.php)
  7. Vim is modal • normal (ESC) • insert (i when

    in normal mode) • visual (v when in normal mode) • ...
  8. Viewing a file and navigation • In normal mode •

    Character movement ◦ h j k l • Line movement ◦ ^ $ j k + - • Text movement ◦ w b e ( { } ) • document movement ◦ gg G gk gj • searching ◦ /{pattern}
  9. Inserting text a Append under character A Append at the

    end of line i Insert at character I Insert at the start of line o Insert with new line O Insert with new line above
  10. Deleting text x delete under cursor X delete behind cursor

    d{motion} delete word, sentence, paragraph dd delete line r{char} replace character
  11. copy pasting v go into visual selection mode - all

    other movements work (selecting word/line/paragraph) y yank or copy the selection in buffer yy yank or copy the line in buffer p paste after cursor Ctrl+V (works only in insert mode)
  12. motions/text objects a - ambient i - in w -

    word s - sentence p - paragraph t - tag ‘ - quote “ - double quote
  13. In normal mode daw - delete a word dit -

    delete in tag cit - change in tag
  14. Advanced features placing marks on the file and jumping quickly

    splitting windows auto completion command completion and much, much, much more!
  15. Further reading material 7 Habits of highly effective text editing

    7 Habits of highly effective text editing v2