vi is the classic line editor used by Unix programmers. It seems to have been created before the advent of cursor keys...see the table for moving the cursor.
Follow these fast links:
| Function | Command |
| Edit file | vi filename |
| Function | Command |
| Write to current file | :w |
| Write to new file | :w filename |
| Write over existing file | :w! filename |
| Write and Quit | :wq |
| Quit (if nothing has been changed) | :q |
| Quit (ignoring changes) | :q! |
| Function | Command |
| Open a second file | :e filename |
| Toggle between files | ^6 |
| Function | Command |
| Right one character | RightArrow or l or SPACE |
| Right to end of word | e |
| Right to end of line | $ |
| Right to beginning of word | w |
| Left one character | LeftArrow or h |
| Left to beginning of word | b |
| Left to beginning of line | 0 |
| Left to start of next line | ENTER |
| Up one line | UpArrow or k or - |
| Down one line | DownArrow or j or + |
| Beginning of first line | H |
| Beginning of Middle line | M |
| Beginning of Last line | L |
| To next sentence | ) |
| To previous sentence | ( |
| To next paragraph | } |
| To previous paragraph | { |
| Forward one screen | ^F |
| Forward (Down) ½ screen | ^D |
| Backward one screen | ^B |
| Backward (Up) ½ screen | ^U |
| Scroll window down one line | ^E |
| Scroll window up one line | ^Y |
| Search forward for pattern | /pattern |
| Search backward for pattern | ?pattern |
| Next occurrence forward | n |
| Next occurrence backward | N |
| Function | Command |
| Append after cursor | a |
| Append at end of line | A |
| Insert before cursor | i |
| Insert at beginning of line | I |
| Open new line above current | O |
| Open new line below current | o |
| Function | Command |
| *Change to end of word | cw |
| *Change to end of line | c$ or C |
| *Change to beginning of line | c0 |
| *Substitute for entire line | S |
| *Substitute for current character | s |
| *Replace multiple characters | R |
| Replace current character | r |
| Join current line to next | J |
| Function | Command |
| Delete line(s) | [n]dd |
| Delete to end of current word | dw |
| Delete to end of current line | d$ or D |
| Delete to beginning of current line | d0 |
| Delete current character | x |
| Function | Command |
| Undo previous command | u |
| Undo changes to current line | U |
| Function | Command |
| Copy (yank) line(s) into buffer | [n]Y or [n]yy |
| Copy (yank) word(s) into buffer | [n]yw |
| Copy (yank) to end of line | y$ |
| Copy (yank) to beginning of line | y0 |
| Copy (yank) to buffer x | "xy |
| Put buffer before/above cursor | P |
| Put buffer after/below cursor | p |
| Put from buffer x | "xp |
| Steps | Command |
| Step 1 | Use a Delete command |
| Step 2 | Move the cursor |
| Step 3 | Use p or P |
| Function | Command |
| Review all editor options | :set all |
| Show command mode | :set showmode |
| Hide command mode | :set noshowmode |
| Change tab stop to 3 characters | :set tabstop=3 |
| Show line numbers | :set number |
| Don't show line numbers | :set nonumber |