vi
- Ref: http://dir.yahoo.com/Computers_and_Internet/Software/Text_Editors/vi/
- Syntax: vi file(s)
- Existing file:
- New file:
- The Most Important Diagram You Will Ever See:
- Let's try it:
- Getting out:
- :x<RET> or ZZ
- Exits from vi, saving changes.
- :q!<RET>
- Exits from vi, don't save changes.
- Flying the Cursor:
- h (and left arrow)
- Left one character in current line
- j (and down arrow)
- Down one line
- k (and up arrow)
- Up one line
- l (and right arrow)
- Right one character in current line
- Adding Text:
- i
- Insert text at the cursor position, end with <ESC>.
- a
- Insert text after the cursor position, end with <ESC>.
- Removing Text:
- x
- Remove one character at the cursor position.
- X
- Remove one character before the cursor position,
- Notes:
- That's all you ``really'' need, everything else just does things faster.
- Most commands take an optional repeat number in front.
- Advanced Cursor Movement:
- w
- Move to beginning of next word.
- 7w
- Seven words forward.
- b
- Move to beginning of previous word.
- e
- Move to end of current word.
- ^
- Move to beginning of current line
- $
- Move to end of current line.
- G
- Move to last line in file.
- 1G
- Move to first line in file.
- 59G
- Move to fifty-ninth line in file.
- {
- Back one paragraph.
- }
- Forward one paragraph.
- Advanced insertion (all end with <ESC>:
- A
- Append to end of line.
- o
- Open line below current line, insert.
- O
- Open line above current line, insert.
- Advanced deletion:
- D
- Delete from cursor to end of line.
- dd
- Delete current line.
- 7dd
- Delete current line and the six following.
- dw
- Delete (rest of) current word.
- 7dw
- Delete seven words.
- dG
- Delete from cursor to end of file.
- J
- Join current line with next line.
- Changes (combined delete/insert; end with <ESC>)
- s
- Change character at cursor.
- 7s
- Change seven characters starting at cursor.
- cw
- Change word.
- 7cw
- Change seven words.
- cc
- Change current line.
- 7cc
- Change seven lines.
- C
- Change from cursor to end of line.
- Search/Replace
- /person<RET>
- Search forward to next occurrence of ``person'' (wraps).
- ?person<RET>
- Search backward to prior occurrence of ``person'' (wraps).
- :s/person/citizen<RET>
- Change next ``person'' to ``citizen''
- :1,$s/person/citizen<RET>
- Replace all occurrences of `person' with `citizen'.
- Redo/Undo/Paste
- n
- Redo previous search.
- .
- Redo previous insertion/deletion.
- u
- Undo previous insertion/deletion (very useful).
- p
- Paste previous deletion after cursor.
- P
- Paste previous deletion at cursor.
On to More Shell Stuff...