vi用法集锦( 二 )


subcommand by pressing the Esc key. If you need information about the format of
vi subcommands, see "vi General Subcommand Syntax."[Number]G Places the cursor at the line number specified by the Number parameter
or at the last line if the Number parameter is not specified./Pattern Places the cursor at the next line containing the character string
specified by the Pattern parameter.?Pattern Places the cursor at the next previous line containing the character
string specified by the Pattern parameter.n Repeats the last search for the text specified by the Pattern parameter in the
same direction.N Repeats the last search for the text specified by the Pattern parameter in the
opposite direction./Pattern/ Number Places the cursor the specified number of lines after the line
matching the character string specified by the Pattern parameter.?Pattern?-Number Places the cursor the specified number of lines before the line
matching the character string specified by the Pattern parameter.% Finds the parenthesis or brace that matches the one at current cursor
position.Editing TextThe subcommands for editing enable you to perform the following tasks:o Marking a specific location in a file and returning
o Adding text to a file
o Changing text while in input mode
o Changing text from command mode
o Copying and moving text
o Restoring and repeating changesMarking a Specific Location in a File and ReturningEnter the following subcommands in command mode. You can cancel an incomplete
subcommand by pressing the Esc key. If you need information about the format of
vi subcommands, see "vi General Subcommand Syntax."" Moves the cursor to the previous location of the current line." Moves the cursor to the beginning of the line containing the previous location
of the current line.mx Marks the current position with the letter specified by the x parameter.`x Moves the cursor to the mark specified by the x parameter."x Moves the cursor to the beginning of the line containing the mark specified
by the x parameter.Adding Text to a File (Text Input Mode)Enter the following subcommands in command mode to change the vi editor into
text input mode. If you need information about the format of vi subcommands, see
"vi General Subcommand Syntax."aText Inserts text specified by the Text parameter after the cursor. End text
input mode by pressing the Esc key.AText Adds text specified by the Text parameter to the end of the line. End text
input mode by pressing the Esc key.iText Inserts text specified by the Text parameter before the cursor. End text
input mode by pressing the Esc key.IText Inserts text specified by the Text parameter before the first nonblank
character in the line. End text input mode by pressing the Esc key.o Adds an empty line below the current line. End text input mode by pressing the
Esc key.O Adds an empty line above the current line. End text input mode by pressing the
Esc key.Changing Text While in Input ModeUse the following subcommands only while in text input mode. These commands have
different meanings in command mode. If you need information about the format of
vi subcommands, see "vi General Subcommand Syntax."Ctrl-D Goes back to previous autoindent stop.^ Ctrl-D Ends autoindent for this line only.0Ctrl-D Moves cursor back to left margin.Esc Ends insertion and returns to command state.Ctrl-H Erases the last character.Ctrl-Q Enters any character if xon is disabled.Ctrl-V Enters any character.Ctrl-W Erases the last small word.Quotes the erase and kill characters.Ctrl-? Interrupts and ends insert or the Ctrl-D key sequence.Changing Text from Command ModeUse the following subcommands in command mode. An incomplete subcommand can be
canceled by pressing the Esc key. If you need information about the format of vi
subcommands, see "vi General Subcommand Syntax."C Changes the rest of the line (same as c$).cc Changes a line.cw Changes a word.cwText Changes a word to the text specified by the Text parameter.D Deletes the rest of the line (same as d$).dd Deletes a line.dw Deletes a word.J Joins lines.rx Replaces the current character with the character specified by x.RText Overwrites characters with the text specified by the Text parameter.s Substitutes characters (same as cl).S Substitutes lines (same as cc).u Undoes the previous change.x Deletes a character at the cursor.X Deletes a character before the cursor (same as dh).

推荐阅读