Monday, December 31, 2012

VI --From Solaris 10: The Complete Reference

VI
--From Solaris 10: The Complete Reference
The following commands can be executed in command mode:

  • /  Performs a forward search for a text string.
  • ?  Performs a backward search for a text string.
  • :  Runs an ex editor command on the current line.
  • !  Executes a shell within vi.
  • ZZ  Saves a file and exits.
  • h  Moves the cursor left.
  • j  Moves the cursor down.
  • k  Moves the cursor up.
  • l  Moves the cursor right.
  • nG  Moves the cursor to line n.
  • w  Moves to next the word.
  • b  Moves back one word.
  • dw  Deletes words.
  • ndw  Deletes n words.
  • d^  Deletes all words to the beginning of the line.
  • dd  Deletes the current line.
  • dG  Deletes all lines to the end of the file.
  • D  Deletes all words to the end of the line.
  • x  Deletes the current character.
  • nx  Deletes the n characters to the right.
  • nY  Yanks n lines into the buffer.
  • p  Pastes to the right of the cursor.
  • P  Pastes to the left of the cursor.
A separate set of commands, called the ex commands, can be run by using the colon in conjunction with one of these commands:
  • :n  Moves the cursor to line n.
  • :$  Moves the cursor to the end of the file.
  • : s/a/b/g  Replaces all occurrences of string a with string b on the current line.
  • :%s/a/b/g  Replaces all occurrences of string a with string b in the entire file.
  • :wq  Saves the modified file and quits.
  • :q!  Quits without saving any changes.
  • :set  Sets a number of different options.

No comments:

Post a Comment