Successfully reported this slideshow.

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Related Audiobooks

Free with a 14 day trial from Scribd

See all

Vim survival guide

  1. 1. The Vim Survival Guide Ben McCormick Windsor Circle Twitter: @ben336 Blog:
  2. 2. Who Am I? • Software Engineer at Windsor Circle • Vim user since 2013 • Wrote a series of blogs on Vim in 2014
  3. 3. So What Is Vim? • Open Source Text editor created in 1991, based on an earlier text editor (vi) created in 1976 for UNIX • Terminal based, but can be used in UI • Some variation on it or vi is shipped in ~all *nix operating systems • Charityware
  4. 4. So What Is Vim?
  5. 5. What To Expect • Intro: Context + History • Part 1: Surviving Vim • Why? • How? • Part 2: Using Vim • Why? • How?
  6. 6. Vim’s Reputation
  7. 7. Vim’s Reputation
  8. 8. Vim’s Reputation
  9. 9. Vim’s Reputation
  10. 10. Vim’s Reputation
  11. 11. Vim’s Reputation
  12. 12. Vim’s Reputation
  13. 13. Vim’s Reputation: Fair Criticism • Tough initial learning curve • Truly bad defaults (Bad beginner UX) • Alien for most modern users
  14. 14. Vim’s Reputation: Myths • Too old to be relevant • Not really efficient • Tough learning curve lasts forever • Bad (power user) UX
  15. 15. Editor Wars • Vi vs Emacs • Many more options now • But Vim stands apart
  16. 16. vi IDEs
  17. 17. Vim has different ideas about: • Shortcut keys • Copy and paste • File system integration / management • Configuration • Keyboard vs mouse use • Naming conventions
  18. 18. Why use Vim at all? • Ubiquitous • Many other editors don't run in a terminal
  19. 19. Surviving Vim: Minimal knowledge • Vim is a modal editor • Vim has a visual editor and a command prompt (ex) editor
  20. 20. What is a modal editor? • Commands are contextual • Depending on what mode you’re in different keystrokes do different things
  21. 21. What is a modal editor? In this mode, typing `dd` deletes the current line In this mode, typing `dd` writes out 2 ds at the start of the line
  22. 22. Vim Modes • Normal Mode • Insert Mode • Visual Mode • Others (less important)
  23. 23. Normal mode • “Normal” • default when Vim is opened • Keystrokes are commands • From other modes use `esc` to switch to normal mode
  24. 24. Insert Mode • More normal for modern users • Keystrokes insert text • commands are possible with key combinations • From normal mode use `i` to switch to insert mode
  25. 25. Visual Mode • For Highlighting/text selection • keystrokes are commands • From normal mode use `v` to switch to visual mode
  26. 26. Ex Commands / Command Prompt • From normal mode `:` to trigger ex commands • File menu equivalent • Used for opening, closing files and the editor, find and replace, command line integration, more
  27. 27. Starting Vim
  28. 28. Opening Files • :e/:edit to open a new file • :sp/:split or :vs/:vsplit for opening in a split
  29. 29. Opening Files
  30. 30. Closing Files • :w/:write to save • :q/:quit or :qall/:quitall to quit • :wq to save and quit • :q! to force quit with unsaved changes
  31. 31. Closing Files
  32. 32. Navigating Files • Encourages use of hjkl instead of the arrow keys • Arrow keys still work • Mouse might or might not work depending on your environment
  33. 33. Navigating Files
  34. 34. Navigating Files
  35. 35. Vim Survival • Remember that Vim is modal • Insert mode is “normal editing” mode • Normal mode is “command mode” • :w to save, :q to quit, :q! to quit decisively :)
  36. 36. Resources • vimtutor •
  37. 37. Using Vim for real
  38. 38. Why use Vim over [Sublime/Atom/VS/IntelliJ/XCode/etc] ? • A beautiful editing language • Command Line living • Top notch flexibility and configurability
  39. 39. Caveats • Bad defaults • Learning Curve • Low UI polish • Plugin Development
  40. 40. Vim as language • Motions: hjkl, w, b • Verbs: d, v
  41. 41. Vim as language • dh -> delete one character to the left • dl -> delete one character to the right • dw -> delete to the start of the next word • db -> delete back to the start of the current word
  42. 42. Vim as language
  43. 43. Vim as language • More Motions: G/gg, f<char> • More Verbs: gU, c
  44. 44. Vim as language • dG - delete everything to the end of the file • gUf. - all-caps to the next `.` • cw - delete to the start of the next word, and then enter insert mode to replace the text
  45. 45. Vim as language • Text objects: iw, i( • Double verbs apply to the whole line
  46. 46. Vim as language • di( - delete everything inside the current parens • gUiw - all-caps the current word • dd - delete the current line • cc -delete the current line and move to insert mode
  47. 47. Vim as language
  48. 48. Vim as language • verb + motion/text object -> action • Each new command you learn works with existing concepts • Everyone has their own “accent”
  49. 49. Vim as Language: Repetition • dot command `.` repeats the previous action (combo of verb and motion/text object) • You can use plain motions in between
  50. 50. Vim as Language: Repetition • dw to delete to the start of the next word • `..` to repeat 2 more times
  51. 51. Vim as Language: Repetition
  52. 52. Vim as a modern editor • Fixing bad defaults comes through configuration in ~/.vimrc file • Control look and feel, custom commands •
  53. 53. Vim as a modern editor
  54. 54. Vim as a modern editor • Feature parity with other editors comes through plugins • • Many plugin managers with Github compatibility (pathogen, vundle, vim-plug) • Plugins are ~100% open source, you can make your own!
  55. 55. Vim as a modern editor
  56. 56. Vim as a modern editor
  57. 57. Vim as a modern editor
  58. 58. Vim as a modern editor • Fuzzy-finder • Linting • Git Integration • AutoComplete • Status bars • Command line integration
  59. 59. Resources • Practical Vim by Drew Neil • •
  60. 60. Vim Language Elsewhere • Neovim: a rethinking of Vim • Vim modes: Sublime, Atom, IntelliJ, Visual Studio • Command Line: vim modes for bash, zsh, fish • Elsewhere: Gmail has vi-inspired shortcuts
  61. 61. Questions?
  62. 62. Ben McCormick Windsor Circle Twitter: @ben336 Blog:

Editor's Notes

  • Hi everybody. Isn’t this exciting? I’m thankful to get to have a cool event like this in the Triangle.

    My name is Ben, and I’m going to be talking about Vim today.

    This talk is a bit different than some of the other talks here

    practical not theory
    I’m talking about a 25 year old piece of software, not something new and shiny

    To start, lets take a quick poll:

    How many of you have heard of Vim?

    How many of you have used Vim?

    How many of you use Vim regularly?

    Cool. Something for each of you etc
  • yes I’m the type of geek who decides to write long blog posts about a text editor
  • Text editor - general purpose, writing code, editing text files, writing prose

    Donate to help children in Uganda (about a million dollars)

    Vi - created by Bill Joy

    Vim - Bram Moolenaar
  • Text editor - general purpose, writing code, editing text files, writing prose

    Vi - created by Bill Joy

    Vim - Bram Moolenaar
  • Title of the talk is Vim Survival Guide

    Why ever NEED to use Vim

    Why you’d ever WANT to use Vim

    One thing we need to talk about first
  • Learning curve starts hard and stays hard
  • Even the people who use it can find it very frustrating
  • Simple things aren’t simple

    True story, I actually got an email a few weeks ago from somebody who decided to write this book for real and put it on Amazon. He wanted me to review the book.
  • Complicated and Scary!! / lots of arbitrary memorization
  • Take the Jedi skeptic POV: It was great in the old days
  • Vim users are annoying and not as productive as they think
  • The thing is… a lot of people use and care about Vim
  • Initial learning curve
  • Initial learning curve
  • Emacs - lightweight, fast text editors, with pluggable functionality, that you control with complex key combinations
  • Shortcut keys - modal editors
    Copy and paste - multiple clipboards, doesn’t integrate smoothly with modern OSes by default
    Very text based rather than UI based in terms of file system integration, splits and buffer list rather than tabs (yes tabs are a thing but they’re weird)
    Way more stuff is configurable than other editors, way more stuff requires configuration than other editors
    This is a keyboard driven show
    Buffer rather than file, delete/yank/put rather than cut/copy/paste, edit/write/ rather than open/save
  • Ubiquitous - make sure to point out that servers still matter for the windows folks in the audience
  • Visual editor (you can see the text of the file and change it)

    Command prompt editor (you can enter commands)
  • select, command line ex-mode
  • Examples:
    x in normal mode, delete current character
    j in normal mode , go down
  • ctrl + w will delete the word before the cursor
  • :e /edit
  • :e /edit
  • :e /edit
  • Controversial statement: This is a dumb way to use Vim if you don’t care about using Vim
  • FF advance setting warning screen

    seems appropriate
  • G - bottom
    gg - top
  • G - bottom
    gg - top
  • in word

    in parens
  • G - bottom
    gg - top
  • Neovim - currently similar to vim may evolve

    Vim modes - the editing language in a more modern frame
  • ×