1. Most Important enter normal mode :q quit vim :wq save and quit vim :qa! force quit without saving any changes :help run from shell: vimtutor 2. Modes normal insert command visual select ex 3. Navigation h left k j down h l k up j l right in vim: arrow keys also work in vi: do not try to use arrow keys w/W next word b/B previous word e/E end of word 0 or ^ beginning of line $ end of line f[char] place cursor on char t[char] place cursor before char ) jump forward one sentence ( jump backward one sentence } jump forward one paragraph { jump backward one paragraph H top of the screen (think: "high") M middle of the screen L bottom of the screen (think: "low") zz center current line in screen gg top of the file G bottom of the file half-page down half-page up page down page up G or : goto line number n m[char] mark current position at register [char] `[char] jump to position at register [char] 4. Insert Text i insert before char a insert after char ("append") I insert at beginning of line A insert at end of line o edit now line below current line ("open line") O edit new line above current line 5. Delete/Change Text x delete current character X delete left character dw delete word d0 delete to beginning of line d$ or D delete to end of line dd delete line dG delete to end of file cw change word ci[character] change inside cc change line -------------------------------------------------- Use counts: 5dw delete 5 words 42dd delete 42 lines Use the . command to repeat the last command 6. Copy-Paste yy copy line yw copy word p paste after P paste before "*p paste from X clipboard :registers 7. Undo u undo redo :undolist U undo all changes on current line careful with original vi: no undo stack! only last change 8. Buffers, Windows, Tabs buffer: text of a file in the memory window: view on a buffer tab: collection of windows :ls list of buffers :e filename edit file in current buffer :new [filename] open split window :vnew [filename] open vertical split window :tabnew open new tab :tabedit [filename] open file in new tab :bn next buffer :bp previous buffer gt next tab gT previous tab +Direction move focus to windows gf open file under cursor K open manpage for word under cursor try vimdiff! 9. Search and Replace / foo search for foo n jump to next hit s/foo/bar/ replace foo with bar %s/foo/bar/ replace foo with bar in whole file :bufdo %s/foo/bar/ :windo %s/foo/bar/ :tabdo %s/foo/bar/ 10. Advanced Text Editing Text Completion: and in insert mode: complete words in insert mode: complete line Visual Mode: v select characters V select lines select columns J join lines Reformatting: gqap reformat current paragraph Handy Stuff: ~ Swap Case increment number decrement number gk, gj, gh, gl move in wrapped (long) lines Macros: qq record to register q do something q stop recording @q apply macro from register q 11. Shell Commands :r read stuff :! run command :r !cmd read output from command 12. Cool Stuff I use Daily but Forgot to Mention in the Talk vim someArchive.tar.bz2 - use vim to edit archives folding with zf, za built-in blowfish encryption: vim -x file paste word under cursor into command mode with calculate in insert mode using =16*16 External tools: vidir from moreutils - edit directory contents with vim vipipe from moreutils - interactive pipes