vi(1)									vi(1)



NAME

  vi, vedit, view - Edits files with a full screen display

SYNOPSIS

  vi [-ls] [-R] | [-r] [-c subcommand] [-t tag] [-wnumber] [+subcommand] [-]
       [file ...]

  view [-l] [-t tag] [-c subcommand] [-wnumber] [+subcommand] [-] [file ...]

  vedit [-l] [-R] | [-r] [-t tag] [-wnumber] [-] [file ...]

  The vi command is a display editor that is based on an underlying line edi-
  tor (ex).

FLAGS

  -c subcommand
      Executes the specified ex subcommand (command) before displaying the
      file for which the editor was invoked.

  -l  Indents appropriately for LISP code, and accepts the (, ), {, }, [, and
      ] characters (parentheses, braces, and brackets) as text rather than
      interpreting them as vi subcommands.  The LISP modifier is active in
      open or visual modes.

  -r[file]
      Recovers file after an editor or system crash.  If you do not specify a
      file, vi displays a list of all saved files.

  -s  Invokes vi in open mode.	(Silent mode.)

  -R  Sets the readonly option to protect the file against overwriting.

  -t tag
      Edits the file containing the tag and positions the editor at its
      definition.  To use this flag, you must first create a database of
      function names and their locations using the ctags command.

  -v  Invokes the visual editor.  When the -v flag is specified, an enlarged
      set of subcommands is available, including screen editing and cursor
      movement features.

  -wnumber
      Sets the default window size to number.  This is useful when you use
      the editor over a low-speed line.

  -   Suppresses all interactive user feedback.	 If you use this flag, file
      input/output errors do not generate an error message.

  +[subcommand]
      Performs the ex subcommand before editing begins.	 If you do not
      specify subcommand, the cursor is placed on the first line of the file.

DESCRIPTION

  The ex editor subcommands can be used within the vi editor, because vi is
  based on ex.	The view command is a read-only version of vi; the readonly
  option is set to protect files during browsing.  The vedit command is a
  version of vi intended for beginners.	 In it, the report option is set to
  1, the showmode option is set, and the novice option (making vedit a line
  editor, rather than a screen editor) is set.	(For more information on
  these options, see Setting Options.)

  The file argument specifies the files to be edited.  If you supply more
  than one file on the command line, vi edits each file in the order speci-
  fied.

  When you use vi, changes you make to a file are reflected on your display.
  The position of the cursor on the display indicates its position within the
  file.	 The subcommands affect the file at the cursor position.

  Limitations of the vi Editor

  The maximum limits of the vi editor are as follows:

    +  2048 bytes per line

    +  256 bytes per global command list

    +  128 bytes in the previous inserted and deleted text

    +  128 bytes in a shell escape command

    +  128 bytes in a string-valued option

    +  30 bytes in a tag name

    +  128 map macros with 2048 bytes total.

  Editing Modes

  The vi editor has the following operational modes:

  Command mode
      When you start the vi editor, it is in Command mode.  Any subcommand
      can be entered from this mode, except commands that can only be used in
      the Text Input mode (those subcommands that make corrections during
      text insertion).	When subcommands and the other modes end, vi returns
      to Command mode.	Pressing the  key cancels a partial subcommand.

  Text Input mode
      Entered by the a, A, i, I, o, O, cx (where x represents the scope of
      the subcommand), C, s, S, and R subcommands.  After entering one of
      these commands, you can enter text into the editing buffer at the
      current cursor position.	To return to Command mode, press  for
      normal exit or press the Interrupt key sequence to end abruptly.

  Last Line mode
      Some subcommands (those with the prefix : (colon), / (slash), ? (ques-
      tion mark), or !!) read input on a line displayed at the bottom of the
      screen.  When you enter the initial character, vi places the cursor at
      the bottom of the screen, where you enter the remaining characters of
      the command.  Press  to perform the subcommand and enter the
      Interrupt key sequence to cancel it.

      When !! is used, the cursor moves only after the two exclamation points
      are entered.  When : is used, special meaning is given to the following
      characters if used as counts before a command:

      %	  All lines, regardless of cursor position

      $	  Last line

      .	  Current line

  Setting Options

  The vi editor allows you to customize options so that you can use the edi-
  tor for a specific task.  Use the set command to set or change an option.
  To view the current setting of options, enter :set all while in vi Command
  mode.

  Some options are set to a string or a number value; other options are sim-
  ply turned on or off.	 To change an option that is set to a value, enter a
  command in the form :set option=value.  To toggle an option that can be set
  to on or off, enter a line of the form :set option to set it to on or :set
  nooption to set it to off.

  Options can be abbreviated in a set command.	The following table lists
  some of vi's options, along with abbreviations and descriptions:

  Option		 Abbreviation	Description

  [no]autoindent	 ai

					Indents automati-
					cally in Text mode
					to the indentation
					on the previous
					line by using the
					spacing between tab
					stops specified by
					the shiftwidth
					option.	 The
					default is noai.
					To back the cursor
					up to the previous
					tab stop, type
					.  This
					option is not in
					effect for global
					commands.

  [no]autoprint		 ap

					Prints the current
					line after any com-
					mand that changes
					the editing buffer.
					The default is ap.
					This option applies
					only to the last
					command in a
					sequence of com-
					mands on a single
					line, and is not in
					effect for global
					commands.









  [no]autowrite		 aw

					Writes the editing
					buffer to the file
					automatically
					before the :n, :ta,
					, and !
					subcommands if the
					editing buffer was
					changed since the
					last write command.
					The default is
					noaw.





























































  [no]beautifying text	 bf

					Prevents user from
					entering control
					characters (except
					for tab, newline,
					and formfeed) in
					the editing buffer
					during text entry.
					The default is
					nobf.  This option
					does apply to com-
					mand input.

  directory		 dir=

					Displays the direc-
					tory that contains
					the editing buffer.
					The default is
					dir=/var/tmp.

  [no]edcompatible	 ed

					Retains global (g)
					and confirms (c)
					subcommand suffixes
					during multiple
					substitutions and
					causes the read (r)
					suffix to work like
					the r subcommand.
					The default is
					noed.

  [no]errorbells	 eb

					Precedes error mes-
					sages with an
					 character.
					Setting this option
					off (noeb) does not
					suppress the alert-
					ing in visual mode.
					The default is
					noeb.

  [no]exrc		 "!

					If not set, ignores
					any .exrc file in
					the current direc-
					tory during ini-
					tialization, unless
					the current direc-
					tory is that named
					by the HOME vari-
					able.  The default
					is noexrc.

  [no]flash		 fl

					Uses visual flash
					rather than audible
					bell.  The default
					is fl.






  hardtabs		 ht=

					Tells vi the dis-
					tance between the
					hardware tab stops
					on your display.
					The default is
					ht=8.


































































  [no]ignorecase	 ic

					Ignores the dis-
					tinction between
					uppercase and
					lowercase while
					searching for regu-
					lar expressions.
					The default is
					noic.

  [no]lisp		 lisp

					Enters vi in LISP
					mode.  In this
					mode, vi appropri-
					ately indents for
					LISP code and the
					(, ), {, }, [[, and
					]].  The default is
					nolisp.

  [no]list		 list

					Displays text with
					tabs and the end of
					lines marked.  Tabs
					are displayed as ^I
					and the end of
					lines as $.  The
					default is nolist.

  [no]magic		 magic

					Treats the charac-
					ters ., [, and * as
					special characters
					in scans.  In Off
					mode, only the (,
					), and $ characters
					retain special
					meanings; however,
					special meaning of
					other characters
					can still be
					invoked by preced-
					ing the character
					with a \
					(backslash).  The
					default is magic.


















  [no]modeline		 modeline

					Runs an editor com-
					mand line if found
					in the first five
					and the last five
					lines of the file.
					An editor command
					line may be any-
					where in a line.
					To be recognized as
					a command line, it
					must contain a
					space or a tab fol-
					lowed by the string
					ex: or vi:.  The
					command line is
					ended by a second :
					(colon).  The edi-
					tor tries to inter-
					pret any data
					between the first
					and second : as
					editor commands.
					The default is
					nomodeline.











































  [no]number		 nu

					Displays lines pre-
					fixed with their
					line numbers.  The
					default is nonu.

  [no]optimize		 opt

					Speeds up the
					operation of termi-
					nals that do not
					have cursor
					addressing.  The
					default is noopt.

  paragraphs		 para=

					Defines macro names
					that start para-
					graphs.	 The
					default is
					para=IPLPPPQPP LIp-
					plpipnpbp.  Single
					letter nroff mac-
					ros, such as .P
					must include the
					space as a quoted
					character if
					respecifying a
					paragraph.

  [no]prompt		 prompt

					Prompts for command
					mode input with a :
					(colon).  When not
					set, no prompt is
					displayed.  The
					default is on.

  readonly		 "

					Allows writing to a
					different file.	 In
					addition, the write
					can be forced by
					using the ! (excla-
					mation point) char-
					acter (see the edi-
					tor command write).
					The default is off,
					unless the file
					lacks write permis-
					sion or the -R flag
					is specified.

  [no]redraw		 re

					Simulates a smart
					display on a dumb
					display.  The
					default is nore.

  [no]remap		 remap

					Enables following
					of map keys.  For
					example, if remap
					is set, map u k map
					r u causes r to map
					to k.  If noremap
					is set, r maps to
					u.  The default is
					remap.




  report		 report=

					Sets the number of
					repetitions of a
					command before a
					message is
					displayed.  For
					subcommands that
					can produce a
					number of messages,
					such as global sub-
					commands, the mes-
					sages are displayed
					when the command is
					completed.  The
					default is
					report=5.

























































  scroll		 scr=

					Sets the number of
					lines to be
					scrolled when you
					scroll the screen
					up or down.  The
					default scroll is
					one-half the size
					of the screen.

  sections		 sect=

					Defines macro names
					that start sec-
					tions.	The default
					is sect=NHSHH
					HUuhsh+c.  Single
					letter nroff mac-
					ros, such as .P
					must include the
					space as a quoted
					character if
					respecifying a
					paragraph.

  shell			 sh=

					Defines the shell
					for ! or :! com-
					mands.	The default
					is the value of the
					SHELL environment
					variable.

  shiftwidth		 sw=

					Sets the distance
					for the software
					tab stops used by
					autoindent, the
					shift commands (>
					and <), and the
					text input commands
					( and
					) to allow
					the editor to
					indent text and
					move back to a pre-
					vious indentation.
					The default is
					sw=8.

  [no]showmatch		 sm

					Shows the matching
					open parenthesis (
					or open brace { as
					you type the close
					parenthesis ) or
					close brace }.	The
					default is nosm.

  [no]showmode		 smd

					Displays mode indi-
					cator at the bottom
					of the screen when
					in the insert or
					replace mode.  The
					default is nosmd.

  [no]slowopen		 slow

					Postpones updating
					the display during
					inserts.  The
					default is noslow.


  [no]sourceany

					Allows the use of
					the source command
					on a file that a
					user does not own.
					The default is
					nosourceany.

  tabstops		 ts=

					Sets the distance
					between tab stops
					when a file is
					displayed.  The
					default is ts=8.

  taglength		 tl=

					Determines length
					of tag.

  [no]tags		 tag

					Specifies a list of
					possible filenames
					of tag files.  The
					default is tags
					/usr/lib/tags.

  term			 term=

					Sets the kind of
					display you are
					using.	The default
					is term=$TERM,
					where $TERM is the
					value of the TERM
					shell variable.

  [no]terse		 terse

					Allows vi to
					display the short
					form of messages.
					The default is
					noterse.

  [no]timeout		 to

					Sets a time limit
					of 2 seconds on
					entry of charac-
					ters.  This limit
					allows the charac-
					ters in a macro to
					be entered and pro-
					cessed as separate
					characters when
					timeout is set.	 To
					resume use of the
					macro, set
					notimeout.  The
					default is to.
  ttytype		 tty=

					Same as term.









  [no]warn		 warn

					Displays a warning
					message before the
					! subcommand exe-
					cutes a shell com-
					mand if this is the
					first time you
					issued a shell com-
					mand after a given
					set of changes were
					made 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.
					The default is
					dependent on the
					baud rate at which
					you are operating:
					600 baud or less /
					8 lines, 1200 baud
					/ 16 lines, higher
					speeds / full
					screen minus 1.

  wrapmargin		 wm=

					Sets the margin for
					automatic wordwrap-
					ping from one line
					to the next.  A
					value of 0 indi-
					cates no wordwrap-
					ping.  The default
					is wm=0.

  [no]wrapscan		 ws

					Allows string
					searches to wrap
					from the end of the
					editing buffer to
					the beginning.	The
					default is ws.

  wraptype		 wt=

					Causes words to be
					wrapped in Japanese
					style.
					wraptype=general
					causes general-
					purpose wrap on
					word breaks, where
					word break is
					defined as whi-
					tespace or space
					between two non-
					ASCII characters.
					general is a combi-
					nation of word and
					flexible.
					wraptype=word
					causes wrap on
					words.
					wraptype=rigid
					causes wrap on
					column and before
					closing punctua-
					tion.
					wraptype=flexible
					causes wrap on
					column, but closing
					punctuation may
					extend past the
					margin.


  [no]writeany		 wa

					Turns off the
					checks usually made
					before a write com-
					mand.  The default
					is nowa.

  Defining Macros

  If you use a subcommand or sequence of subcommands frequently, you can
  create a macro that issues the subcommand or sequence when you call a
  macro.  To create a macro, enter the sequence of subcommands into an edit-
  ing buffer named with a letter of the alphabet.  When used as buffer names,
  lowercase ASCII letters a through z overlay the contents of the buffer,
  while uppercase ASCII letters A through Z append text to the previous con-
  tents of the buffer, allowing the building of a macro piece by piece.

  To invoke the macro, enter @x, where x is the letter name of the buffer.
  Enter @@  to repeat the last macro you invoked.

  Mapping Keys

  You can use the map command to set a keystroke to a subcommand or a
  sequence of subcommands.  To set a key mapping, enter :map key subcommand
  where key is the key to which you want to assign a subcommand or sequence
  of subcommands and subcommand is the subcommand or sequence of subcommands.
  For example, to set @ to delete lines, enter:

       :map  @	dd

  In this example, @ is the key to which the subcommand is assigned and dd is
  the subcommand.

  In the next example, a subcommand sequence is mapped to a key:

       :map * {>}

  The * (asterisk) is the key to which the subcommand sequence is assigned
  and {>} is the subcommand sequence.  The { (open brace) moves the cursor to
  the beginning of the paragraph and the > (right angle bracket) indents the
  paragraph to the next shiftwidth.

  To display the list of the current key mappings while you are in Command
  mode, enter the :map command.	 You can also remove a key mapping.  To
  remove a key mapping, enter :unmap string or :unmap! string where string is
  the string used after the :map command to set the key and subcommand
  sequence.  For example, to remove key mapping for the previous example,
  enter:

       :unmap *

  If function keys are defined for your terminal, they can be put in a map or
  unmap command by typing  then pressing the desired key.  In this
  way, function keys that are unused during editing can be mapped to useful
  editing subcommand sequences.

  If the ! (exclamation point) character is appended to the command name map
  (map!), the mapping is effective during input mode rather than during
  visual mode.

  Abbreviations

  You can define abbreviations for long phrases that you use often.  vi then
  automatically expands these abbreviations whenever you enter them in insert
  mode. Only single-byte characters can appear in abbr_string; abbr_string
  cannot contain Asian multi-byte characters.

  To define an abbreviation, enter:

       :abbr abbreviation phrase

  abbreviation is the abbreviation you specify for the longer text specified
  by phrase.  For example, to specify the abbreviation imho for the phrase In
  my humble opinion, enter:

       :abbr imho In my humble opinion

  Keeping a Customized Change

  When you customize vi from the vi command line, the customized editor is in
  effect until you exit the editor. If you want to reuse such things as
  option settings and key mappings, you must put them in the .exrc file in
  your home directory or define the EXINIT environment variable.  The vi edi-
  tor processes the commands given in the EXINIT variable or reads the .exrc
  file each time you invoke it. Here is an example of an .exrc file:

       set ai aw
       set wm=5
       map  @  dd

  Users with both a .exrc file and an EXINIT environment variable will find
  that the vi editor no longer reads the .exrc file. This change was made to
  meet the specifications of XPG4.

  The standard provides for an approximation of the old behavior. A new vari-
  able, named exrc, is defined. When this variable is set by the commands in
  the EXINIT environment variable, the editor reads .exrc in the current
  directory for additional startup commands. For example:

       setenv EXINIT 'set ai terse magic bf wm=1 exrc'

  Additionally, the editor refuses to read the .exrc file if its mode grants
  write permission to anyone other than the owner; this restriction prevents
  certain security breaches.  No overt indication is given when such a
  refusal occurs.

  vi Character Sets

  The collation sequence, as defined by the value of the LC_COLLATE environ-
  ment variable, defines the alphanumeric set used by your system.  This
  table affects the performance of vi macros and subcommands.

  The vi editor uses the collation sequence to distinguish between a small
  word and a big word.	A small word is bounded by letters or numbers as
  defined in the collation table.  For example, isn't is two small words.
  The ' (apostrophe) is not a number or an alphabetic character, and it
  bounds both the small word t and the small word isn.	A big word is bounded
  by spaces, tabs, or newline indicators.  For example, stop is a big word.
  For more information, see the section Moving to Words.

  Subcommand Syntax


  [named_buffer] [operator] [number] argument

  Surrounding brackets indicate optional items.

  [named_buffer]
      A temporary text storage area.

  [operator]
      Specifies the subcommand or action; instructs the vi editor.

  [number]
      A whole decimal value that specifies either the extent of the action or
      a line address.  The vi editor interprets this number in one of the
      following ways:

       1.
	Go to line number:
	     5G
	     10z


       2.
	Go forward number columns.
	     25


       3.
	Scroll number of lines:
	     10
	     10


       4.
	Delete number lines:
	     6dd


       5.
	% means all.  To yank all lines:
	     %y


	(The preceding command replaces 1,$y.)

  argument
      Specifies what to act on.	 This can be a text object (a character,
      word, sentence, paragraph, section, or character string) or a text
      position (a line, position in the current line, or screen position).

  Moving Within a File

  Enter the following subcommands in Command mode.  You can cancel an incom-
  plete subcommand by pressing the  key.

  , h, 
      Moves the cursor one character to the left.

  , j, , 
      Moves the cursor down one line, remaining in the same column.

  , k, 
      Moves the cursor up one line, remaining in the same column.

  , l 
      Moves the cursor one character to the right.

      Long lines:  Lines over one screen width are wrapped but not broken.
      When using the Up Arrow or Page Up key, @ lines are added at the bottom
      of the screen when too few physical lines are available to display the
      complete line.  The Down Arrow key moves the entire line off the screen
      at once.

  Character Positioning Within a Line

  Enter the following subcommands in Command mode.

  ^   Moves the cursor to the first nonspace character.

  0   Moves the cursor to the beginning of the line.

  $   Moves the cursor to the end of the line.

  fx  Moves the cursor to the next x character.

  Fx  Moves the cursor to the last x character.

  tx  Moves the cursor to one column before the next x character.

  Tx  Moves the cursor to one column after the last x character.

  ;   Repeats the last f, F, t, or T subcommand.

  ,   Repeats the last f, F, t, or T subcommand in the opposite direction.

  number
      Moves the cursor to the specified column.

  Moving to Words

  Enter the following subcommands in Command mode.

  w   Moves the cursor to the next small word.

  b   Moves the cursor to the previous small word.

  e   Moves the cursor to the end of the next small word.

  W   Moves the cursor to the next big word.

  B   Moves the cursor to the previous big word.

  E   Moves the cursor to the end of the next big word.

  Moving by Line Positioning

  Enter the following subcommands in Command mode.

  G   Moves to the line number given as preceding argument, or the end of the
      file if no preceding count is given.

  H   Moves the cursor to the top line on the screen.

  L   Moves the cursor to the last line on the screen.

  M   Moves the cursor to the middle line on the screen.

  +   Moves the cursor to the next line, at its first nonspace character.

  -   Moves the cursor to the previous line, at its first nonspace character.

  
      Moves the cursor to the next line, at its first nonspace character.

  Moving to Sentences, Paragraphs, or Sections

  Enter the following subcommands in Command mode.  You can cancel an incom-
  plete subcommand by pressing the  key.

  (   Places the cursor at the beginning of the previous sentence (or the
      previous S-expression if you are in LISP mode).

  )   Places the cursor at the beginning of the next sentence (or the next
      S-expression if you are in LISP mode).

  {   Places the cursor at the beginning of the previous paragraph (or at the
      next list if you are in LISP mode).

  }   Places the cursor at the beginning of the next paragraph, at the next
      section if you are in C mode, or at the next list if you are in LISP
      mode.

  |   Requires a count; the cursor is placed in that column (if possible).

  ]]  Places the cursor at the next section, or function if you are in LISP
      mode.

  [[  Places the cursor at the previous section, or function if you are in
      LISP mode.

  Paging and Scrolling


  
      Scrolls up (default 12 lines).

  
      Scrolls down (default 12 lines).

  
      Pages forward one screen.

  
      Pages backward one screen.

  
      Scrolls the window up one line.

  
      Scrolls the window down one line.

  
      Moves to the first non-white character in the next line.	A count
      specifies the number of lines to go forward.

  
      Inserts shiftwidth white space in input mode, if at the beginning of
      the line or preceded only by white space.	 This inserted space can only
      be backed over using .

  
      Cancels a partially formed command; sounds the bell if there is none.

      In input mode, terminates input mode.

      When entering a command on the bottom line of the screen (ex command
      line or search pattern with \ or ?), terminates input and executes com-
      mand.

  z+  Pages up.

  z^  Pages down.

  Searching for Patterns

  The following commands allow you to search for patterns within a file.
  Patterns can be regular expressions as described for grep.

  /pattern
      Places the cursor at the next line containing pattern.

  ?pattern
      Places the cursor at the next previous line containing pattern.

  n   Repeats the last search for pattern in the same direction.

  N   Repeats the last search for pattern in the opposite direction.

  /pattern/+number
      Places the cursor at the numberth line after the line matching pattern.

  ?pattern?-number
      Places the cursor at the numberth line before the line matching pat-
      tern.

  %   Finds the parenthesis or brace that matches the one at the current cur-
      sor position.

  
      Finds the word at the cursor in the tags file then edits the proper
      file, placing the cursor at the tag.  If the tag is in the current
      file, moves cursor to it.

  Marking and Returning

  Enter the following subcommands in Command mode.  You can cancel an incom-
  plete subcommand by pressing the  key.

  ``  Moves the cursor to the same cursor position of the previous current
      line.

  ''  Moves the cursor to the beginning of the previous current line.

  mx  Marks the current position with the letter specified by x.

  `x  Moves the cursor to the same cursor position of line marked x.

  'x  Moves the cursor to the beginning of the line marked x.

  Adjusting the Screen

  Enter the following subcommands in Command mode.  An incomplete subcommand
  can be canceled by pressing the  key.

  
      Clears and redraws the screen.

  
      Redraws the screen and eliminates blank lines marked with a @.

  z
      Redraws the screen with the current line at the top of the screen.

  z-  Redraws the screen with the current line at the bottom of the screen.

  z.  Redraws the screen with the current line at the center of the screen.

  /pattern/z-
      Redraws the screen with the line containing pattern at the bottom.

  znumber
      Makes the window number lines long.



  Adding Text to a File--Text Input

  The following subcommands are entered in Command mode and bring the vi edi-
  tor into Text Input mode to allow you to add text to your file.  End Text
  Input mode by pressing the  key.

  atext
      Inserts text after the cursor.

  Atext
      Adds text to the end of the line.

  itext
      Inserts text before the cursor.

  Itext
      Inserts text before the first nonspace character in the line.

  o   Adds an empty line below the current line.

  O   Adds an empty line above the current line.

  Changing Text While in Input Mode

  Use the following commands only while in Text Entry mode.  They have dif-
  ferent meanings in Command mode.

  
      Erases the last character.

  
      Erases the last small word.  (For more information about small words,
      see the section vi Character Sets.)

  \   Quotes the Erase and Kill characters.

  
      Ends insertion, back to Command mode.

  Quit key sequence
      Interrupts, terminates insert or .

  
      Goes back to the previous autoindent stop.

  ^
      Ends autoindent for this line only.

  0
      Moves the cursor back to the left margin.

  
      Quotes a nonprinting character.

  Changing Text from Command Mode

  Use the following subcommands in Command mode.  An incomplete subcommand
  can be canceled by pressing the  key.

  C   Changes the rest of the line (c$).

  c   Must be followed by a movement command.  Deletes the specified region
      of text and enters input mode to replace it with the entered text.  If
      more than part of a single line is affected, the deleted text is saved
      in the numeric buffers.  If only part of the current line is affected,
      the last character to be deleted is marked with a $.  A count is passed
      through to the move command.  If the command is cc, the whole of the
      current line is changed.

  cc  Changes a line.

  cw  Changes a word.

  D   Deletes the rest of the line (d$) and puts it into the undo buffer.

  d   Must be followed by a movement command.  Deletes the specified region
      of text.	If more than part of a line is affected, the text is saved in
      the numeric buffers.  A count is passed through to the move command.
      If the command is dd, the whole of the current line is deleted.

  dd  Deletes a line and puts it into the undo buffer.

  dw  Deletes a word and puts it into the undo buffer.

  J   Joins lines.

  rx  Replaces the current character with the character specified by x.

  R   Overwrites characters.

  s   Substitutes characters (cl).

  S   Substitutes lines (cc).

  u   Undoes the previous change.

  x   Deletes a character.

  X   Deletes characters before cursor (dh).

  <<  Shifts one line 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.
      (The > character describes a range upon which the L subcommand acts.)

  ~   Changes the letter at the cursor to the opposite case.

  Copying and Moving Text

  Use the following subcommands in Command mode.  An incomplete subcommand
  can be canceled by pressing .

  p (P)
      Puts back text in the undo buffer after (before) the cursor.

  "xp (xP)
      Puts back text from the buffer x after (before) the cursor.  You must
      precede the character x with a double quote.

  "xdobject
      Deletes object into the buffer x.	 You must precede the character x
      with a double quote.

  yobject
      Yanks object into the undo buffer (for example, yw to yank a word).

  "xyobject
      Yanks object into buffer x.  You must precede the character x with a
      double quote.

  Y   Places the line in the undo buffer.


  Restoring and Repeating Changes

  Use the following subcommands in Command mode.  An incomplete subcommand
  can be canceled by pressing the  key.

  u   Undoes the last command.

  U   Restores the current line if the cursor has not left the line since the
      last change.

  .   Repeats the last change or increments the np command.

      Note that this command is not meant for use with a macro.	 Enter @@ to
      repeat a macro.

  "np Retrieves the nth last delete of a complete line or block of lines.
      You must precede the character n with a double quote.

  Saving Changes to a File

  Use the following subcommands in Command mode.  An incomplete subcommand
  can be canceled by pressing .  If you are using these subcommands
  within the ex editor, you do not need to type the : (colon).

  :w  Writes the editing buffer contents to the original file.

  :w file
      Writes the editing buffer contents to the named file.

  :w! file
      Overwrites file with the editing buffer contents.

  Interrupting, Cancelling, and Exiting vi


  Q   Enters the ex editor in Command mode.

  ZZ  Exits vi, saving changes, if any were made.

  :q  Quits vi.	 If you have changed the contents of the editing buffer, vi
      displays a warning message and does not quit.

  :q! Quits vi, discarding the editing buffer with no warning.

  :sh Runs a shell.  You can return to vi by pressing .

  :w !command
      Runs the file through the specified shell command (causes no change to
      the file).

  :!command
      Runs command, then returns.

  :!! Repeats the last :!command command.

  n!!command
      Executes the shell command identified by command and replaces the
      number of lines specified by n with the output of command.  If n is not
      specified, the default is 1.  If command expects standard input, the
      lines specified are used as input.  (10!!sort sorts the next 10 lines.)

  !linescommand
      Works like n!!command, except that lines is a line address (for exam-
      ple, !Gsort sorts the rest of the file).

  Quit key sequence
      Interrupts a subcommand.

  Editing a Second File

  Enter the following subcommands in Command mode.  An incomplete subcommand
  can be canceled by pressing the  key.

  :e file
      Edits file.  If you are using this subcommand from the ex editor, you
      do not need to type the : (colon).

  :e! Reedits the current file and discards all changes.

  :e  +	 file
      Edits file, starting at the end.

  :e  +number
      Edits file, starting at the line number.

  :e # and 
      Edits the alternate file.	 The alternate file is usually the previous
      current filename.	 However, if changes are pending on the current file
      when a new file is called, the new file becomes the alternate file.

  :r file
      Reads the file into the editing buffer by adding new lines below the
      current line.  If you are using this subcommand from the ex editor, you
      do not need to type the : (colon).

  :r !command
      Runs the shell command identified by command and places its output in
      the file by adding new lines below the current cursor position.

  :ta tag
      Edits a file containing tag at the location of tag.  If the tag is in
      another file and the current file has been changed (and noaw is set), a
      warning is posted.  To use this command, you must first create a data-
      base of function names and their locations using the ctags command.  If
      you are using this subcommand from the ex editor, you do not need to
      type the : (colon).

  
      Finds the word at the cursor in the tags file and edits the indicated
      file, placing the cursor at the tag.  Same as :ta, but the tag is the
      word to the right of the cursor.

  Editing a List of Files

  Enter the following subcommands in Command mode.

  :n  Edits the next file in the list entered on the command line.

  :n file ...
      Specifies a new list of files to edit.

  Displaying File Information

  Enter the following subcommand in Command mode to show the current
  filename, the current line number, the number of lines in the file, and the
  percentage of lines of the file that are before the cursor:

  




RELATED INFORMATION

  Commands:  ctags(1), ed(1)/red(1), edit(1), ex(1),
  grep(1)/fgrep(1)/egrep(1), nroff(1)