📄 vi.hlp
字号:
Commands Reference, Volume 6vi or vedit CommandPurposeEdits files with a full-screen display.Syntax{ vi | vedit } [ -l ] [ -R ] [ -tTag ] [ -v ] [ -wNumber] [ -yNumber ] [ -r [File ] ] [{ + | -c } { Subcommand } ] [ File ... ]DescriptionThe vi command starts a full-screen editor based on the underlying ex editor.Therefore, ex subcommands can be used within the vi editor. The vedit commandstarts a version of the vi editor intended for beginners. In the vedit editor,the report option is set to 1, the showmode option is set, and the novice optionis set, making it a line editor.You start the vi editor by specifying the name of the file or files to beedited. If you supply more than one File parameter on the command line, the vieditor edits each file in the specified order. The vi editor on an existing filedisplays the name of the file, the number of lines, and the number of charactersat the bottom of the screen. In case of multibyte locales the number ofcharacters need to be interpreted as the number of bytes.Since the vi editor is a full-screen editor, you can edit text on ascreen-by-screen basis. The vi editor makes a copy of the file you are editingin an edit buffer, and the contents of the file are not changed until you savethe changes. The position of the cursor on the display screen indicates itsposition within the file, and the subcommands affect the file at the cursorposition.vi Editor LimitationsThe following list provides the maximum limits of the vi editor. These countsassume single-byte characters. o {LINE_MAX} characters per line o 256 characters per global command list o 128 characters in the previously inserted and deleted text o 128 characters in a shell escape command o 128 characters in a string-valued option o 30 characters in a tag name o 128 map macros with 2048 characters total o 1,048,560 lines of {LINE_MAX} characters per line silently enforced o The macro name and the macro text are limited to 100 characters.Note Running the vi editor on a file larger than 64MB may cause the followingerror message to display:0602-103 file too large to place in /tmpvi Editing ModesThe vi editor operates in the following modes:command mode When you start the vi editor, it is in command mode. You can enterany subcommand except those designated for use only in the text input mode. Thevi editor returns to command mode when subcommands and other modes end. Pressthe Esc key to cancel a subcommand.text-input mode You use the vi editor in this mode to add text. Enter text inputmode with any of the following subcommands: the a subcommand, A subcommand, isubcommand, I subcommand, o subcommand, O subcommand, cx subcommands (where thex represents the scope of the subcommand), C subcommand, s subcommand, Ssubcommand, and R subcommand. After entering one of these subcommands, you canenter text into the editing buffer. To return to command mode, press the Esc keyfor normal exit or press Interrupt (the Ctrl-C key sequence) to end abnormally.last-line mode Subcommands with the prefix : (colon), / (slash), ? (questionmark), ! (exclamation point), or !! (two exclamation points) read input on aline displayed at the bottom of the screen. When you enter the initialcharacter, the vi editor places the cursor at the bottom of the screen, whereyou enter the remaining characters of the command. Press the Enter key to runthe subcommand, or press Interrupt (the Ctrl-C key sequence) to cancel it. Whenthe !! prefix is used, the cursor moves only after both exclamation points areentered. When you use the : prefix to enter the last-line mode, the vi editorgives special meaning to the following characters when they are used beforecommands that specify counts:% All lines regardless of cursor position$ Last line. Current lineCustomizing the vi EditorYou can customize the vi editor by: o Setting vi editor options o Defining macros o Mapping keys o Setting abbreviationsSetting vi Editor OptionsThe following list describes the vi editor options you can change with the setcommand. The default setting for these options is off. If you turn on one ofthese toggle options, you can turn it off again by entering the word no beforethe option. If you want to discontinue the autowrite vi option, enter noaw,where no turns off the option and aw specifies the autowrite option. Note Do notinclude parentheses when entering vi options.vi Option (Abbreviation) Descriptionautoindent (ai) Indents automatically in text input mode to the indentation ofthe previous line by using the spacing between tab stops specified by theshiftwidth option. The default is noai. To back the cursor up to the previoustab stop, press the Ctrl-D key sequence. This option is not in effect for globalcommands.autoprin (ap) Prints the current line after any command that changes the editingbuffer. The default is ap. This option applies only to the last command in asequence of commands on a single line and is not in effect for global commands.autowrite (aw) Writes the editing buffer to the file automatically before the :nsubcommand, the :ta subcommand, the Ctrl-A key sequence, and the ! subcommand ifthe editing buffer changed since the last write subcommand. The default is noaw.beautifying text (bf) Prevents the user from entering control characters in theediting buffer during text entry (except for tab, new-line, and form-feedindicators). The default is nobf. This option applies to command input.closepunct (cp=) Handles a list of closing punctuation, especially when wrappingtext (wraptype option). Precedes multicharacter punctuation with the number ofcharacters; for example, cp=3..;)}. The vi command does not split closingpunctuation when wrapping.directory (dir=) Displays the directory that contains the editing buffer. Thedefault is dir = /var/tmp.edcompatible (ed) Retains g (global) and c (confirm) subcommand suffixes duringmultiple substitutions and causes the r (read) suffix to work like the rsubcommand. The default is noed.exrc (exrc) If not set, ignores any .exrc file in the current directory duringinitialization, unless the current directory is that named by the HOMEenvironment variable. The default is noexrc.hardtabs (ht=) Tells the vi editor the distance between the hardware tab stopson your display screen. (This option must match the tab setting of theunderlying terminal or terminal emulator.) The default is ht=8.ignorecase (ic) Ignores distinction between uppercase and lowercase whilesearching for regular expressions. The default is noic.linelimit (ll=) Sets the maximum number of lines, as per the -y command-lineoption. This option only is effective if used with the .exrc file or the EXINITenvironment variable.lisp (lisp) Removes the special meaning of ( ), { }, [ [, and ] ] and enablesthe = (formatted print) operator for s-expressions, so you can edit listprocessing (LISP) programs. The default is nolisp.list (list) Displays text with tabs (^I) and the marked end of lines ($). Thedefault is nolist.magic (magic) Treats the . (period), [ (left bracket), and * (asterisk)characters as special characters when searching for a pattern. In off mode, onlythe ( ) (parentheses) and $ (dollar sign) retain special meanings. However, youcan evoke special meaning in other characters by preceding them with a \(backslash). The default is magic.mesg (mesg) Turns on write permission to the terminal if set while in visualmode. This option only is effective if used with the .exrc file or the EXINITenvironment variable. The default is on.modeline (modeline) Runs a vi editor command line if found in the first five orthe last five lines of the file. A vi editor command line can be anywhere in aline. For the vi editor to recognize a command line, the line must contain aspace or a tab followed by the ex: or vi: string. The command line is ended by asecond : (colon). The vi editor tries to interpret any data between the firstand second colon as vi editor commands. The default is nomodeline.novice Indicates whether you are in novice mode. You cannot change the value byusing the set command.number (nu) Displays lines prefixed with their line numbers. The default isnonu.optimize (opt) Speeds the operation of terminals that lack cursor addressing.The default is noopt.paragraphs (para=) Defines vi macro names that start paragraphs. The default ispara=IPLPPPQPP\ LIpplpipnpbp. Single-letter nroff macros, such as the .P macro,must include the space as a quoted character if respecifying a paragraph.partialchar (pc=) Appears in the last display column where a double-widecharacter would not be displayed completely. The default character is - (minussign).prompt Prompts for a new vi editor command when in command mode by printing a :(colon). The default is on.readonly (ro) Sets permanent read-only mode. The default is noreadonly.redraw (redraw) Simulates a smart workstation on a dumb workstation. The defaultis nore.remap Allows defining macros in terms of other macros. The default is on.report (re=) Sets the number of times you can repeat a command before a messageis displayed. For subcommands that produce many messages, such as globalsubcommands, the messages are displayed when the command sequence completes. Thedefault is report=5.scroll (scr=) Sets the number of lines to be scrolled when the user scrolls upor down. The default is 1/2 of the window size, rounded down.sections (sect=) Defines vi macro names that start sections. The default issect=NHSHHH\ HUuhsh+c. Single-letter nroff macros, such as the .P macro, mustinclude the space as a quoted character if respecifying a paragraph.shell (sh=) Defines the shell for the ! subcommand or the :! subcommand. Thedefault is the login shell.shiftwidth (sw=) Sets the distance for the software tab stops used by theautoindent option, the shift commands ( > and < ), and the text input commands (the Ctrl-D and Ctrl-T key sequences). This vi option only affects theindentation at the beginning of a line. The default is sw=8.showmatch (sm) Shows the ( (matching left parenthesis) or { (left bracket) asyou type the ) (right parenthesis) or } (right bracket). The default is nosm.showmode (smd) Displays a message to indicate when the vi editor is in inputmode. The default is nosmd.slowopen (slow) Postpones updating the display screen during inserts. Thedefault is noslow.tabstop (ts=) Sets the distance between tab stops in a displayed file. Thedefault is ts=8.tags (tags =) Defines the search path for the database file of function namescreated using the ctags command. The default is tags=tags\ /usr/lib/tags.term (term=) Sets the type of workstation you are using. The default isterm=$TERM, where $TERM is the value of the TERM shell variable.terse (terse) Allows the vi editor to display the short form of messages. Thedefault is noterse.timeout (to) Sets a time limit of two seconds on an entry of characters. Thislimit allows the characters in a macro to be entered and processed as separatecharacters when the timeout option is set. To resume use of the macro, set thenotimeout option. The default is to.ttytype Indicates the tty type for the terminal being used. You cannot changethis value from the vi editor.warn (warn) Displays a warning message before the ! subcommand executes a shellcommand if it is the first time you issued a shell command after changes weremade in the editing buffer but not written to a file. The default is warn.window (wi=) Sets the number of lines displayed in one window of text. Thedefault depends on the baud rate at which you are operating: 600 baud or less, 8lines; 1200 baud, 16 lines; higher speeds, full screen minus 1 line.wrapmargin (wm=) Sets the margin for automatic word wrapping from one line tothe next. The default is wm=0. A value of 0 turns off word wrapping.wrapscan (ws) Allows string searches to wrap from the end of the editing bufferto the beginning. The default is ws.wraptype (wt=) Indicates the method used to wrap words at the end of a line. Thedefault value is general. You can specify one of the following four values:general Allows wraps on word breaks as white space between two characters. This setting is the default.word Allows wraps on words.rigid Allows wraps on columns and before closing punctuation.flexible Allows wraps on columns, but one character of punctuation can extend past the margin.writeany (wa) Turns off the checks usually made before a write subcommand. Thedefault is nowa.To see a list of the vi editor settings that have changed from the defaultsettings, enter set and press the spacebar. Press the Enter key to return to thecommand mode.To see a complete list of the vi editor settings, enter set all. Press the Enterkey to return to the command mode.To turn on a vi editor option, enter set Option. This command automaticallyreturns you to the command mode.To turn on multiple vi editor options, enter set Option Option Option. Thiscommand turns on the three designated vi editor options and returns you to thecommand mode.To turn off a vi editor option, enter set noOption. This command automaticallyreturns you to the command mode.To change the value of a vi editor option, enter set Option=Value. This commandautomatically returns you to the command mode.You can use the :set subcommand of the vi editor to set options for this editingsession only, or to set options for this editing session and all future editingsessions.To set or change vi editor options for this editing session only, enter the :set
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -