Skip to content

Instantly share code, notes, and snippets.

@davidxia
Created September 20, 2012 20:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidxia/3758165 to your computer and use it in GitHub Desktop.
Save davidxia/3758165 to your computer and use it in GitHub Desktop.
NYC Lunch and Learn - September 21, 2012 - Neville Li & David Xia

NYC Lunch and Learn

September 21, 2012

Neville Li & David Xia

To me vi is zen. To use vi is to practice zen. Every command is a koan. Profound to the user, unintelligible to the uninitiated. You discover truth every time you use it. — Satish Reddy

Vim Basics

Movement

  • i → Insert mode. Type ESC to return to Normal mode.
  • x → Delete the char under the cursor
  • :wq → Save and Quit (:w save, :q quit)
  • dd → Delete (and copy) the current line
  • p → Paste
  • hjkl
  • 0 → go to the first column
  • ^ → go to the first non-blank character of the line
  • $ → go to the end of line
  • g_ → go to the last non-blank character of line

Inserting

  • a → insert after the cursor
  • o → insert a new line after the current one
  • O → insert a new line before the current one
  • cw → replace from the cursor to the end of the word

Search

  • /pattern → search for pattern

Copy/Paste

  • P → paste before, remember p is paste after current position.
  • yy → copy the current line, easier but equivalent to ddP

Undo/Redo

  • u → undo
  • → redo

Load/Save/Quit

  • :e <path/to/file> → open
  • :w → save
  • :saveas <path/to/file> → save to <path/to/file>
  • :x, ZZ or :wq → save and quit (:x only save if necessary)
  • :q! → quit without saving, also: :qa! to quit even if there are modified hidden buffers.

Buffers, Tabs, and Splits

  • :ls list buffers

  • :b 6 open sixth buffer

  • :tabnew opens new tab

  • :gt and :gT for moving between tabs

  • :3gt go to 3rd tab

  • :tabm 3 to move tab to 4th position

  • :ctrl-W s to open horizontal split

  • :ctrl-W v to open vertical split

Plugins

Plugin Managers

Navigation

Git

Further Reading

@davidxia
Copy link
Author

My vim config
Neville's vim config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment