Saving and Quitting
- ^\
- Quit out of "VI" mode and go into "EX" mode. The EX editor is the line editor VI is build upon. The EX command to get back into VI is ":vi".
- Q
- Quit out of "VI" mode and go into "EX" mode. The ex editor is a line-by-line editor. The EX command to get back into VI is ":vi".
- ZZ
- Exit the editor, saving if any changes were made.
Miscellany
- ^G
- Show the current filename and the status.
- ^L
- Clear and redraw the screen.
- ^R
- Redraw the screen removing false lines.
- ^[
- Escape key. Cancels partially formed command.
- ^^
- Go back to the last file edited.
- !
- Execute a shell. If a
is specified, the program which is executed using ! uses the specified line(s) as standard input, and will replace those lines with the standard output of the program executed. "!!" executes a program using the current line as input. For example, "!4jsort" will take five lines from the current cursor position and execute sort. After typing the command, there will be a single exclamation point where you can type the command in. - &
- Repeat the previous ":s" command.
- .
- Repeat the last command that modified the file.
- :
- Begin typing an EX editor command. The command is executed once the user types return. (See section below.)
- @
- Type the command stored in the specified buffer.
- U
- Restore the current line to the state it was in before the cursor entered the line.
- m
- Mark the current position with the character specified after the 'm' command.
- u
- Undo the last change to the file. Typing 'u' again will re-do the change.
EX Commands
The VI editor is built upon another editor, called EX. The EX editor only edits by line. From the VI editor you use the : command to start entering an EX command. This list given here is not complete, but the commands given are the more commonly used. If more than one line is to be modified by certain commands (such as ":s" and ":w" ) the range must be specified before the command. For example, to substitute lines 3 through 15, the command is ":3,15s/from/this/g".
- :ab string strings
- Abbreviation. If a word is typed in VI corresponding to string1, the editor automatically inserts the corresponding words. For example, the abbreviation ":ab usa United States of America" would insert the words, "United States of America" whenever the word "usa" is typed in.
- :map keys new_seq
- Mapping. This lets you map a key or a sequence of keys to another key or a sequence of keys.
- :q
- Quit VI. If there have been changes made, the editor will issue a warning message.
- :q!
- Quit VI without saving changes.
- :s/pattern/to_pattern/options
- Substitute. This substitutes the specified pattern with the string in the to_pattern. Without options, it only substitutes the first occurence of the pattern. If a 'g' is specified, then all occurences are substituted. For example, the command ":1,$s/Dwayne/Dwight/g" substitutes all occurences of "Dwayne" to "Dwight".
- :set [all]
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




