Distribution
************

   Copyright (C) 1987 Masahiko Sato.

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.

   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.

   Permission is granted to copy and distribute translations of this
manual into another language, under the same conditions as for modified
versions.

Insert Mode
===========

   You can enter insert mode by one of the following commands.  In
addition to these, you will enter insert mode if you give a change
command with a line command as the motion command.  Insert commands are
also modifying commands and you can repeat them by the repeat command
`.' (`vip-repeat').

`i'
     Enter insert mode at point (`vip-insert').

`I'
     Enter insert mode at the first non white character on the line
     (`vip-Insert').

`a'
     Move point forward by one character and then enter insert mode
     (`vip-append').

`A'
     Enter insert mode at end of line (`vip-Append').

`o'
     Open a new line below the current line and enter insert mode
     (`vip-open-line').

`O'
     Open a new line above the current line and enter insert mode
     (`vip-Open-line').

`C-o'
     Insert a newline and leave point before it, and then enter insert
     mode
     (`vip-open-line-at-point').

   Insert mode is almost like emacs mode.  Only the following 4 keys
behave differently from emacs mode.

`ESC'
     This key will take you back to vi mode (`vip-change-mode-to-vi').

`C-h'
     Delete previous character (`delete-backward-char').

`C-w'
     Delete previous word (`vip-delete-backward-word').

`C-z'
     This key simulates ESC key in emacs mode.  For instance, typing
     `C-z x' in insert mode iw the same as typing `ESC x' in emacs mode
     (`vip-ESC').

You can also bind `C-h' to `help-command' if you like.  (see
Customizing Key Bindings, for details.)  Binding `C-h' to
`help-command' has the effect of making the meaning of `C-h' uniform
among emacs, vi and insert modes.

   When you enter insert mode, VIP records point as the start point of
insertion, and when you leave insert mode the region between point and
start point is saved for later use by repeat command etc.  Therefore,
repeat command will not really repeat insertion if you move point by
emacs commands while in insert mode.

Ex Commands
***********

   In vi mode, you can execute an Ex command EX-COMMAND by typing:
     `: EX-COMMAND RET'
   Every Ex command follows the following pattern:
     ADDRESS COMMAND `!' PARAMETERS COUNT FLAGS

where all parts are optional.  For the syntax of "address", the reader
is referred to the reference manual of Ex.

   In the current version of VIP, searching by Ex commands is always
"magic".  That is, search patterns are always treated as "regular
expressions".  For example, a typical forward search would be invoked by
`:/PAT/'.  If you wish to include `/' as part of PAT you must preceded
it by `\'.  VIP strips off these `\''s before `/' and the resulting PAT
becomes the actual search pattern.  Emacs provides a different and
richer class or regular expressions than Vi/Ex, and VIP uses Emacs'
regular expressions.  See GNU Emacs Manual for details of regular
expressions.

   Several Ex commands can be entered in a line by separating them by a
pipe character `|'.

Ex Command Reference
====================

   In this section we briefly explain all the Ex commands supported by
VIP.  Most Ex commands expect ADDRESS as their argument, and they use
default addresses if they are not explicitly given.  In the following,
such default addresses will be shown in parentheses.

   Most command names can and preferably be given in abbreviated forms.
In the following, optional parts of command names will be enclosed in
brackets.  For example, `co[py]' will mean that copy command can be
give as `co' or `cop' or `copy'.

   If COMMAND is empty, point will move to the beginning of the line
specified by the ADDRESS.  If ADDRESS is also empty, point will move to
the beginning of the current line.

   Some commands accept "flags" which are one of `p', `l' and `#'.  If
FLAGS are given, the text affected by the commands will be displayed on
a temporary window, and you will be asked to hit return to continue.
In this way, you can see the text affected by the commands before the
commands will be executed.  If you hit `C-g' instead of RET then the
commands will be aborted.  Note that the meaning of FLAGS is different
in VIP from that in Vi/Ex.

`(.,.) co[py] ADDR FLAGS'
`(.,.) t ADDR FLAGS'
     Place a copy of specified lines after ADDR.  If ADDR is `0', it
     will be placed before the first line.

`(.,.) d[elete] REGISTER COUNT FLAGS'
     Delete specified lines.  Text will be saved in a named REGISTER if
     a lower case letter is given, and appended to a register if a
     capital letter is given.

`e[dit] ! +ADDR FILE'
`e[x] ! +ADDR FILE'
`vi[sual] ! +ADDR FILE'
     Edit a new file FILE in the current window.  The command will abort
     if current buffer is modified, which you can override by giving
     `!'.  If `+'ADDR is given, ADDR becomes the current line.

`file'
     Give information about the current file.

`(1,$) g[lobal] ! /PAT/ CMDS'
`(1,$) v /PAT/ CMDS'
     Among specified lines first mark each line which matches the
     regular expression PAT, and then execute CMDS on each marked line.
     If `!' is given, CMDS will be executed on each line not matching
     PAT.  `v' is same as `g!'.

`(.,.+1) j[oin] ! COUNT FLAGS'
     Join specified lines into a line.  Without `!', a space character
     will be inserted at each junction.

`(.) k CH'
`(.) mar[k] CH'
     Mark specified line by a lower case character CH.  Then the
     addressing form `''CH will refer to this line.  No white space is
     required between `k' and CH.  A white space is necessary between
     `mark' and CH, however.

`map CH RHS'
     Define a macro for vi mode.  After this command, the character CH
     will be expanded to RHS in vi mode.

`(.,.) m[ove] ADDR'
     Move specified lines after ADDR.

`(.) pu[t] REGISTER'
     Put back previously deleted or yanked text.  If REGISTER is given,
     the text saved in the register will be put back; otherwise, last
     deleted or yanked text will be put back.

`q[uit] !'
     Quit from Emacs.  If modified buffers with associated files exist,
     you will be asked whether you wish to save each of them.  At this
     point, you may choose not to quit, by hitting `C-g'.  If `!' is
     given, exit from Emacs without saving modified buffers.

`(.) r[ead] FILE'
     Read in the content of the file FILE after the specified line.

`(.) r[ead] ! COMMAND'
     Read in the output of the shell command COMMAND after the specified
     line.

`se[t]'
     Set a variable's value.  See Customizing Constants, for the
     list of variables you can set.

`sh[ell]'
     Run a subshell in a window.

`(.,.) s[ubstitute] /PAT/REPL/ OPTIONS COUNT FLAGS'
`(.,.) & OPTIONS COUNT FLAGS'
     On each specified line, the first occurrence of string matching
     regular expression PAT is replaced by replacement pattern REPL.
     Option characters are `g' and `c'.  If global option character `g'
     appears as part of OPTIONS, all occurrences are substituted.  If
     confirm option character `c' appears, you will be asked to give
     confirmation before each substitution.  If `/PAT/REPL/' is
     missing, the last substitution is repeated.

`st[op]'
     Suspend Emacs.

`ta[g] TAG'
     Find first definition of TAG.  If no TAG is given, previously
     given TAG is used and next alternate definition is find.  By
     default, the file `TAGS' in the current directory becomes the
     "selected tag table".  You can select another tag table by `set'
     command.  See Customizing Constants, for details.

`und[o]'
     Undo the last change.

`unm[ap] CH'
     The macro expansion associated with CH is removed.

`ve[rsion]'
     Tell the version number of VIP.

`(1,$) w[rite] ! FILE'
     Write out specified lines into file FILE.  If no FILE is given,
     text will be written to the file associated to the current buffer.
     Unless `!' is given, if FILE is different from the file
     associated to the current buffer and if the file FILE exists, the
     command will not be executed.  Unlike Ex, FILE becomes the file
     associated to the current buffer.

`(1,$) w[rite]>> FILE'
     Write out specified lines at the end of file FILE.  FILE becomes
     the file associated to the current buffer.

`(1,$) wq ! FILE'
     Same as `write' and then `quit'.  If `!' is given, same as `write
     !' then `quit'.

`(.,.) y[ank] REGISTER COUNT'
     Save specified lines into register REGISTER.  If no register is
     specified, text will be saved in an anonymous register.

`ADDR ! COMMAND'
     Execute shell command COMMAND.  The output will be shown in a new
     window.  If ADDR is given, specified lines will be used as standard
     input to COMMAND.

`($) ='
     Print the line number of the addressed line.

`(.,.) > COUNT FLAGS'
     Shift specified lines to the right.  The variable `vip-shift-width'
     (default value is 8) determines the amount of shift.

`(.,.) < COUNT FLAGS'
     Shift specified lines to the left.  The variable `vip-shift-width'
     (default value is 8) determines the amount of shift.

`(.,.) ~ OPTIONS COUNT FLAGS'
     Repeat the previous `substitute' command using previous search
     pattern as PAT for matching.

   The following Ex commands are available in Vi, but not implemented
in VIP.
     `abbreviate', `list', `next', `print', `preserve', `recover', `rewind', `source',
     `unabbreviate', `xit', `z'

Customization
*************

   If you have a file called `.vip' in your home directory, then it
will also be loaded when VIP is loaded.  This file is thus useful for
customizing VIP.

Customizing Constants
=====================

   An easy way to customize VIP is to change the values of constants
used in VIP.  Here is the list of the constants used in VIP and their
default values.

`vip-shift-width 8'
     The number of columns shifted by `>' and `<' command.

`vip-re-replace nil'
     If `t' then do regexp replace, if `nil' then do string replace.

`vip-search-wrap-around t'
     If `t', search wraps around the buffer.

`vip-re-search nil'
     If `t' then search is reg-exp search, if `nil' then vanilla search.

`vip-case-fold-search nil'
     If `t' search ignores cases.

`vip-re-query-replace nil'
     If `t' then do reg-exp replace in query replace.

`vip-open-with-indent nil'
     If `t' then indent to the previous current line when open a new
     line by `o' or `O' command.

`vip-tags-file-name "TAGS"'
     The name of the file used as the tag table.

`vip-help-in-insert-mode nil'
     If `t' then C-h is bound to `help-command' in insert mode, if
     `nil' then it sis bound to `delete-backward-char'.

You can reset these constants in VIP by the Ex command `set'.  Or you
can include a line like this in your `.vip' file:
     (setq vip-case-fold-search t)

Customizing Key Bindings
========================

   VIP uses `vip-command-mode-map' as the "local keymap" for vi mode.
For example, in vi mode, SPC is bound to the function `vip-scroll'.
But, if you wish to make SPC and some other keys  behave like Vi, you
can include the following lines in your `.vip' file.

     (define-key vip-command-mode-map "\C-g" 'vip-info-on-file)
     (define-key vip-command-mode-map "\C-h" 'vip-backward-char)
     (define-key vip-command-mode-map "\C-m" 'vip-next-line-at-bol)
     (define-key vip-command-mode-map " " 'vip-forward-char)
     (define-key vip-command-mode-map "g" 'vip-keyboard-quit)
     (define-key vip-command-mode-map "s" 'vip-substitute)
     (define-key vip-command-mode-map "C" 'vip-change-to-eol)
     (define-key vip-command-mode-map "R" 'vip-change-to-eol)
     (define-key vip-command-mode-map "S" 'vip-substitute-line)
     (define-key vip-command-mode-map "X" 'vip-delete-backward-char)

Key Index
*********

Concept Index
*************