- h - moves cursor one character to the left
- j - moves cursor one line down
- k - moves cursor one line up
- l - moves cursor one character to the right
- ^f - moves cursor one screen forward
- ^d - moves cursor a half screen down
- ^b - moves cursor one screen backward
- ^u - moves cursor a half screen up
- ^ - moves cursor to the beginning of the line
- $ - moves cursor to the end of a line
- w - moves cursor one word forward, with punctuation and braces as new words
- W - moves cursor forward to the next word
- b - moves cursor one word backward, with punctuation and braces as new
words
- B - moves cursor backward to the next word
- /pattern - searches for pattern and moves the cursor there
- pattern - searches backwards for pattern and moves the cursor there li
deleting text
- x - deletes the character the cursor is on
- X - deletes the character to the left of the cursor
- dd - deletes the entire line the cursor is on
- d followed by a cursor movement command deletes that much text. For instance, w moves the cursor forward a word, and dw deletes to the end of the word. The 5h command moves the cursor five characters to the left, and the d5h command deletes five characters to the left.
insurting text
i - inserts text to the left of the cursor (leaves you in insert mode)
a - appends text to the right of the cursor (leaves you in insert mode)
A - appends text at the end of the line (leaves you in insert mode)
o - opens new line under the line the cursor is on (leaves you in insert mode)
O - opens new line above the line the cursor is on (leaves you in insert mode)
save and quit
- :q! - exits without saving changes
- :w - write changes
- :wq - write changes, then qui
Deleting Text
- x delete single character; 5x deletes 5 characters
- dw delete word; 5dw deletes 5 words
- dd delete line; 5dd deletes ... well you get the idea!
- cw delete word, leaves you in insert mode (i.e. change word)
- cc change line -- delete line and start insert mode
- s change character -- delete character and start insert mode
- D delete from cursor to end of line
- C change from cursor to end of line -- delete and start insert mode
- u undo last change
- U undo all changes to current line
- liJ join current line with line that follows (press Enter in insert mode to split line)
Miscellaneous Commands
- Ctrl-g show line number of current line
- Ctrl-l redraw the entire display
- :!sh fork a shell; type Ctrl-d to get back to vi
- . repeat last text change command at current cursor position