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
- 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
- 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
- /pattern → search for pattern
- P → paste before, remember p is paste after current position.
- yy → copy the current line, easier but equivalent to ddP
- u → undo
- → redo
- :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.
-
: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