While in command mode (case sensitive)
- move the cursor with arrow keys; if there aren't any arrow keys, use j,k,h,l (Fn + left/right key to navigate to start/end of line)
- i - change to insert mode (before cursor)
- a - change to insert mode (after cursor)
- A - change to insert mode (at end of line)
- r - replace one character
- R - overwrite text
- x - delete one character
- dd - delete one line
- yy - yank line (copy)
- p - paste deleted or yanked text after cursor
- P - paste deleted or yanked text before cursor
- G - go to end of the file
- 1G - go to top of the file
- J - merge next line with this one
- / - search, follow / with text to find
- :wq - write file and quit
- :q! - quit without saving
- %s/old/new/g - substitute; replace "old" with "new" on all lines
- :g/pattern/d - delete all lines that match the pattern
- 0 - move to the beginning of the current line
- $ - move to end of line
- H - move to the top of the current window (high)
- M - move to the top of the current window (middle)
- L - move to the top of the current window (low)
- 1G - move to the first line of the file
- 20G - move to the bottom line of the file
- G - move to the last line of the file.
- ESC - change to command mode
- any text typed is entered at the cursor
- Type "vi file.txt" at command prompt
- Move cursor to where new text will be added
- Type "i" to change to insert mode
- Type new text
- Type ESC to go back to command mode
- type ":wq" and ENTER to write the file and quit
No comments:
Post a Comment