📄 vi.hlp
字号:
Esc key.Changing Text While in Input ModeUse the following subcommands only while in text input mode. These commands havedifferent meanings in command mode. If you need information about the format ofvi subcommands, see "vi General Subcommand Syntax."Ctrl-DGoes 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 becanceled by pressing the Esc key. If you need information about the format of visubcommands, see "vi General Subcommand Syntax."CChanges the rest of the line (same as c$).ccChanges 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.RTextOverwrites characters with the text specified by the Text parameter.sSubstitutes characters (same as cl).SSubstitutes 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).<< Shifts one line to the left.<L Shifts all lines from the cursor to the end of the screen to the left.>> Shifts one line to the right.>L Shifts all lines from the cursor to the end of the screen to the right.~ Changes letter at the cursor to the opposite case.! Indents for LISP.Copying and Moving TextUse the following subcommands in command mode. An incomplete subcommand can becanceled by pressing the Esc key. If you need information about the format of visubcommands, see "vi General Subcommand Syntax."p Puts back text from the undo buffer after the cursor.P Puts back text from the undo buffer before the cursor."xp Puts back text from the x buffer."xd Deletes text into the x buffer.y Places the object that follows (for example, w for word) into the undo buffer."xy Places the object that follows into the x buffer, where x is any letter.Y Places the line in the undo buffer.Restoring and Repeating ChangesUse the following subcommands in command mode. An incomplete subcommand can becanceled by pressing the Esc key. If you need information about the format of visubcommands, see "vi General Subcommand Syntax."u Undoes the last change.Note After an undo, the cursor moves to the first non-blank character on theupdated current line.U Restores the current line if the cursor has not left the line since the lastchange.. Repeats the last change or increments the "np command.Notes: 1. This subcommand will repeat the last change, including an undo. Therefore, after an undo, repeat performs an undo rather than repeat the last change. 2. This subcommand is not meant for use with a macro. Enter @@ (two at signs) to repeat a macro."n p Retrieves the nth last delete of a complete line or block of lines.Manipulating FilesThe subcommands for manipulating files allow you to do the tasks outlined in thefollowing sections: o Saving changes to a file o Editing a second file o Editing a list of files o Finding file informationSaving Changes to a FileUse the following subcommands in command mode. If you need information about theformat of vi subcommands, see "vi General Subcommand Syntax.":w Writes the edit buffer contents to the original file. If you are using thissubcommand within the ex editor, you do not need to type the : (colon).:w File Writes the edit buffer contents to the file specified by the Fileparameter. If you are using this subcommand within the ex editor, you do notneed to type the : (colon).:w! File Overwrites the file specified by the File parameter with the editbuffer contents. If you are using this subcommand within the ex editor, you donot need to type the : (colon).Editing a Second FileEnter the following subcommands in command mode. If you need information aboutthe format of vi subcommands, see "vi General Subcommand Syntax.":e File Edits the specified file. If you are using this subcommand from the exeditor, you do not need to type the : (colon).:e! Re-edits the current file and discards all changes.:e + File Edits the specified file starting at the end.:e + Number File Edits the specified file starting at the specified line number.:e # Edits the alternate file. The alternate file is usually the previous filename before accessing another file with a :e command. However, if changes arepending on the current file when a new file is called, the new file becomes thealternate file. This subcommand is the same as the Ctrl-A subcommand.:r File Reads the file into the editing buffer by adding new lines below thecurrent line. If you are using this subcommand from the ex editor, you do notneed to type the : (colon).:r !Command Runs the specified command and places its output into the file byadding new lines below the current cursor position.:ta Tag Edits a file containing the Tag tag starting at the location of the tag.To use this subcommand, you must first create a database of function names andtheir locations using the ctags command. If you are using this subcommand fromthe ex editor, you do not need to type the : (colon).Ctrl-A Edits the alternate file. The alternate file is usually the previouscurrent file name. However, if changes are pending on the current file when anew file is called, the new file becomes the alternate file. This subcommand isthe same as the :e # subcommand.Editing a List of FilesEnter the following subcommands in command mode. If you need information aboutthe format of vi subcommands, see "vi General Subcommand Syntax.":n Edits the next file in the list entered on the command line. If you are usingthis subcommand from the ex editor, a : (colon) is not needed.:n Files Specifies a new list of files to edit. If you are using this subcommandfrom the ex editor, a : (colon) is not needed.Finding File InformationEnter the following subcommand in command mode. If you need information aboutthe format of vi subcommands, see "vi General Subcommand Syntax".Ctrl-G Shows the current file name, current line number, number of lines in thefile, and percentage of the way through the file where the cursor is located.Other ActionsThe vi editor provides the subcommands described in the following sections: o Adjusting the screen o Entering shell commands o Interrupting and ending the vi editorAdjusting the ScreenEnter the following subcommands in command mode. An incomplete subcommand can becanceled by pressing the Esc key. If you need information about the format of visubcommands, see "vi General Subcommand Syntax."Ctrl-L Clears and redraws the screen.Ctrl-R Redraws the screen and eliminates blank lines marked with @ (at sign).zNumber Makes the window the specified number of lines long.Entering Shell CommandsThe following subcommands allow you to run a command within the vi editor. Enterthese subcommands in command mode. If you need information about the format ofvi subcommands, see "vi General Subcommand Syntax.":sh Enters the shell to allow you to run more than one command. You can returnto the vi editor by pressing the Ctrl-D key sequence. If you are using thissubcommand within the ex editor, a : (colon) is not needed.:!Command Runs the specified command and then returns to the vi editor. If youare using this subcommand within the ex editor, a : (colon) is not needed.Note The # (alternate file), % (current file), and ! (previous command) specialcharacters are expanded when following a :! subcommand. To prevent any of thesecharacters from being expanded, use the \ (backslash).:!! Repeats the last :!Command subcommand.Number!!Command Runs the specified command and replaces the lines specified byNumber with the output of the command. If a number is not specified, the defaultvalue is 1. If the command expects standard input, the specified lines are usedas input.!Object Command Runs the specified command and replaces the object specified bythe Object parameter with the output of the command. If the command expectsstandard input, the specified object is used as input.Interrupting and Ending the vi EditorEnter the following subcommands in command mode. If you need information aboutthe format of vi subcommands, see "vi General Subcommand Syntax."Q Enters the ex editor in command mode.ZZ Exits the vi editor, saving changes.:q Quits the vi editor. If you have changed the contents of the editing buffer,the vi editor displays a warning message and does not quit. If you are usingthis subcommand from the ex editor, a : (colon) is not needed.:q! Quits the vi editor, discarding the editing buffer. If you are using thissubcommand from the ex editor, a : (colon) is not needed.Esc Ends text input or ends an incomplete subcommand.Ctrl-? Interrupts a subcommand.Exit StatusThe following exit values are returned:0 Indicates successful completion.>0 Indicates an error occurred.Input FilesInput files must be text files or files that are similar to text files exceptfor an incomplete last line that is no longer than LINE_MAX -1 bytes in lengthand contains no null characters.The .exrc files must be text files consisting of ex commands.By default, the vi editor reads lines from the files to be edited withoutinterpreting any of those lines as any form of vi editor command.Related InformationThe ctags command, ed command, ex command, sed command, tvi command, viewcommand.The .profile file.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -