# Open 1+ files
$ vim file
$ vim -p [file|*|*.md] [file]
# Pipe to vim
$ echo foo | vim -
- ESC normal mode
- i insert mode
- v visual mode
- h left
- j down
- k up
- l right
- w start of next word
- e end of word
- b beginning of word
- 0 beginning of line
- $ end of line
- g+g beginning of file
- G end of file
- [n] + G go to line number
- * move to next word under cursor
- # move to previous word under cursor
- /searchterm
- n next search result
- N previous search result
- o insert new line of text
- x delete letter
- X backspace
- r replace letter under cursor without going into insert
- . repeat previous command
- d+d delete line
- d + [n] + w delete n words
- y+y copy line
- y+y+p copy line and paste after current
:! [command]
Commands from within vim
# new tab
:tabnew [file]
# close tab
:tabc
# previous tab
:tabp
# next tab
:tabn [number]
# first tab
:tabr
# last tab
:tabl
# list of open tabs
:tabs
# ?
:next
# write (only if there are changes) and quit
:x
# save
:w [filename]
# quit
:q
# save and quit
:wq
# force save and quit (even without permission)
:wq!
# quit without saving
:q!
# undo
u
# redo
ctrl + R
# help
:help