kiss-repository

personal kiss repository
git clone git://git.ckyln.com/~cem/kiss-repository.git
Log | Files | Refs | Submodules | README | LICENSE

nvi-01-additional_upstream_data.patch (179644B)


      1 #! /bin/sh /usr/share/dpatch/dpatch-run
      2 ## 01additional_upstream_data.dpatch by <hesso@pool.math.tu-berlin.de>
      3 ##
      4 ## DP: A few documentation files cherry-picked from the last stable
      5 ## DP: release tarball, because they are missing in later development
      6 ## DP: branch releases.
      7 
      8 @DPATCH@
      9 diff -Naur nvi-1.81.6.orig/nvi-1.79/FAQ nvi-1.81.6/nvi-1.79/FAQ
     10 --- nvi-1.81.6.orig/nvi-1.79/FAQ	1970-01-01 01:00:00.000000000 +0100
     11 +++ nvi-1.81.6/nvi-1.79/FAQ	1996-10-14 15:52:46.000000000 +0200
     12 @@ -0,0 +1,160 @@
     13 +@(#)FAQ	8.13 (Berkeley) 10/14/96
     14 +
     15 +Q: How can I get vi to display my character set?
     16 +A: Vi uses the C library routine isprint(3) to determine if a character
     17 +   is printable, or should be displayed as an octal or hexadecimal value
     18 +   on the screen.  Generally, if vi is displaying printable characters
     19 +   in octal/hexadecimal forms, your environment is not configured correctly.
     20 +   Try looking at the man pages that allow you to configure your locale.
     21 +   For example, to configure an ISO 8859-1 locale under Solaris using csh,
     22 +   you would do:
     23 +
     24 +	setenv LANG C
     25 +	setenv LC_CTYPE iso_8859_1
     26 +
     27 +   Other LC_CTYPE systems/values that I'm told work:
     28 +
     29 +   System	Value
     30 +   ======	=====
     31 +   FreeBSD	lt_LN.ISO_8859-1
     32 +   HP-UX  9.X	american.iso88591
     33 +   HP-UX 10.X	en_US.iso88591
     34 +   SunOS  4.X	iso_8859_1
     35 +   SunOS  5.X	iso_8859_1
     36 +
     37 +   If there's no other solution, you can use the print and noprint edit
     38 +   options of vi to specify that a specific character is printable or not
     39 +   printable.
     40 +	
     41 +Q: My map won't work!
     42 +A: One thing that you should immediately check if a vi map doesn't work
     43 +   is if depends on the final cursor position after a P or p command.
     44 +   Historic vi's were inconsistent as to the final position of the cursor,
     45 +   and, to make matter worse, the final cursor position also depended on
     46 +   whether the put text came from a named or unnamed buffer!  Vi follows
     47 +   the POSIX 1003.2 standard on this one, and makes this consistent, always
     48 +   placing the cursor on the first character.
     49 +
     50 +Q: I'm using ksh or csh as my vi edit option shell value, and file
     51 +   expansions don't work right!
     52 +A: The problem may be in your ksh or csh startup files, e.g., .cshrc.  Vi
     53 +   executes the shell to do name expansion, and the shell generally reads
     54 +   its startup files.  If the startup files are not correctly configured
     55 +   for non-interactive use, e.g., they always echo a prompt to the screen,
     56 +   vi will be unable to parse the output and things will not work
     57 +   correctly.
     58 +
     59 +Q: How does the iclower edit option differ from the ignorecase (i.e. ic)
     60 +   edit option?
     61 +A: The difference is that the ignorecase edit option always ignores the
     62 +   case of letters in the Regular Expression (RE), and the iclower edit
     63 +   option only ignores the case if there are no upper-case letters in the
     64 +   RE.  If any upper-case letters appear in the Regular Expression, then
     65 +   it will be treated case-sensitively, as if the ignorecase edit option
     66 +   was not set.
     67 +
     68 +Q: When I edit binary files, vi appends a <newline> to the last line!
     69 +A: This is historic practice for vi, and further, it's required by the
     70 +   POSIX 1003.2 standard.  My intent is to provide a command line and/or
     71 +   edit option to turn this behavior off when I switch to version 2.0 of
     72 +   the Berkeley DB package.
     73 +
     74 +Q: My cursor keys don't work when I'm in text input mode!
     75 +A: A common problem over slow links is that the set of characters sent by
     76 +   the cursor keys don't arrive close enough together for vi to understand
     77 +   that they are a single keystroke, and not separate keystrokes.  Try
     78 +   increasing the value of the escapetime edit option, which will cause
     79 +   vi to wait longer before deciding that the <escape> character that
     80 +   starts cursor key sequences doesn't have any characters following it.
     81 +
     82 +Q: When I edit some files, vi seems to hang forever, and I have to kill it.
     83 +A: Vi uses flock(2) and fcntl(2) to do file locking.  When it attempts to
     84 +   acquired a lock for a file on an NFS mounted filesystem, it can hang
     85 +   for a very long (perhaps infinite) period of time.  Turning off the
     86 +   "lock" edit option will keep vi from attempting to acquire any locks
     87 +   on the files you edit.
     88 +
     89 +Q: When I compile vi I get lots of warnings about pointer assignments
     90 +   being incompatible!
     91 +A: Vi is partially written to support wide characters.  When this code
     92 +   interfaces with the code that doesn't yet support wide characters,
     93 +   the pointer types clash.  This will hopefully be fixed in the near
     94 +   future, but I've been saying that for awhile, now.
     95 +
     96 +Q: I get jumpy scrolling behavior in the screen!
     97 +A: This is almost certainly a problem with the system's terminfo or
     98 +   termcap information for your terminal.  If the terminfo/termcap entry
     99 +   doesn't have the settable scrolling region capabilities, or the more
    100 +   powerful scrolling commands, these behaviors can result.  Historic
    101 +   implementations of vi, and some of the vi clones, don't suffer from
    102 +   this problem because they wrote their own screen support instead of
    103 +   using the curses library.
    104 +
    105 +   The solution is to find a good terminfo or termcap entry for your
    106 +   terminal, which will fix the problem for all of the applications on
    107 +   your system, not just vi.  Eric Raymond maintains the freely
    108 +   redistributable termcap/terminfo entries.  They can be downloaded
    109 +   from http://www.ccil.org/~esr/ncurses.html, or you can contact him
    110 +   at esr@snark.thyrsus.com.
    111 +
    112 +Q: The entire screen repaints on every keystroke!
    113 +A: Your system's curses implementation is broken.  You should use the
    114 +   curses implementation provided with vi or a curses replacement such
    115 +   as ncurses.  Eric Raymond is one of the maintainers of the freely
    116 +   redistributable ncurses package.  You can download ncurses from
    117 +   http://www.ccil.org/~esr/ncurses.html, or you can contact him at
    118 +   esr@snark.thyrsus.com.
    119 +
    120 +Q: When I use vi on a Sun console (terminal type sun-34) the screen
    121 +   is occasionally trashed, usually when exiting vi!
    122 +A: The Sun console can't handle the 'al' capability of the termcap
    123 +   entry (the il1 capability of terminfo entries).  If you delete that
    124 +   entry from your terminfo/termcap information everything should work
    125 +   correctly.
    126 +
    127 +Q: I don't have a version of ctags (or I have ctags, but it doesn't tag
    128 +   nearly enough things)!
    129 +A: There's a version of ctags available on the 4.4BSD-Lite distributions,
    130 +   as well as the FreeBSD, NetBSD, Linux and GNU distributions.  Or, you
    131 +   might want to try Exuberant Ctags:
    132 +
    133 +	Title:		Exuberant Ctags
    134 +	Version:	1.3
    135 +	Entered-date:	16JUN96
    136 +	Description:
    137 +	    A better ctags which generates tags for all possible tag types:
    138 +	    macro definitions, enumerated values (values inside enum{...}),
    139 +	    function and method definitions, enum/struct/union tags, external
    140 +	    function prototypes (optional), typedefs, and variable
    141 +	    declarations. It is far less easily fooled by code containing #if
    142 +	    preprocessor conditional constructs, using a conditional path
    143 +	    selection algorithm to resolve complicated choices, and a
    144 +	    fall-back algorithm when this one fails. Can also be used to print
    145 +	    out a list of selected objects found in source files.
    146 +	Keywords:	ctags, tags, exuberant
    147 +	Author:		darren@sirsi.com (Darren Hiebert)
    148 +			darren@hiwaay.net (Darren Hiebert)
    149 +	Maintained-by:	darren@sirsi.com (Darren Hiebert)
    150 +			darren@hiwaay.net (Darren Hiebert)
    151 +	Primary-site:	sunsite.unc.edu /pub/Linux/devel/lang/c
    152 +			27kB ctags-1.3.tar.gz
    153 +	Alternate-site:	ftp.halcyon.com /local/gvr
    154 +			27kB ctags-1.3.tar.gz
    155 +	Original-site:
    156 +	Platforms:	UNIX, MSDOS, WindowsNT, Windows95, OS/2, Amiga
    157 +	Copying-policy:	Public domain
    158 +
    159 +Q: When I update a file I already have open, and use :e to reread it, I
    160 +   get nul's for the rest of the file!
    161 +A: Your system's implementation of mmap(2) has a bug; you will have to
    162 +   exit vi and re-execute it.
    163 +
    164 +Q: Where can I get cscope?
    165 +A: Cscope is available on UNIXWare System V Release 4.0 variants such as
    166 +   Sun Solaris 2.x (/opt/SUNWspro/bin) and UNIXWare System V Release 4.1.
    167 +
    168 +   You can buy version 13.3 source with an unrestricted license for $400
    169 +   from AT&T Software Solutions by calling +1-800-462-8146.  Binary
    170 +   redistribution of cscope is an additional $1500, one-time flat fee.
    171 +
    172 +   For more information, see http://www.unipress.com/att/new/cscope.html.
    173 diff -Naur nvi-1.81.6.orig/docs/changelog nvi-1.81.6/docs/changelog
    174 --- nvi-1.81.6.orig/nvi-1.79/docs/changelog	1970-01-01 01:00:00.000000000 +0100
    175 +++ nvi-1.81.6/nvi-1.79/docs/changelog	1996-10-23 15:39:08.000000000 +0200
    176 @@ -0,0 +1,1102 @@
    177 +1.78 -> 1.79 (10/23/96)
    178 +	+ Rename delete() to del(), for C++.
    179 +	+ Add Spanish to the list of translations.
    180 +	+ Update to Perl 5.003_06, and other Perl interpreter updates.
    181 +	+ Update the set-edit-option interface for the scripting languages.
    182 +	+ Rework ex command parsing to match historic practice for backslash
    183 +	  escaped <newline> characters inside of global commands.
    184 +	+ Enhance the comment edit option to skip C++ comments.
    185 +	+ Change installation to configure the recovery shell script to match
    186 +	  the system pathnames and to install it into the vi data directory.
    187 +	  Move the recover script into the build directory, and delete the
    188 +	  recover directory.
    189 +	+ Enhance LynxOS support.
    190 +1.76 -> 1.78 (10/01/96)
    191 +	+ Fix bugs when both the leftright scrolling and number edit options
    192 +	  were on.
    193 +	+ Fix bug where splitting in the middle of the screen could repaint
    194 +	  incorrectly.
    195 +	+ Fix first-nul in input bug, where random garbage was inserted.
    196 +	+ Correct search and mark-as-motion-command bug, it's a line mode
    197 +	  action if the search starts at or before the first non<blank>.
    198 +	+ Fix bug autoindent bug, where ^D could shift too far in the line.
    199 +	+ Fix core dump where ! command called from the .exrc file.
    200 +	+ Add the -S command-line option, which initializes vi to have the
    201 +	  secure edit option preset.
    202 +1.75 -> 1.76 (09/15/96)
    203 +	+ Fix bug where ^V didn't keep input mapping from happening.
    204 +	+ Fix a core dump bug in the R command.
    205 +	+ Give up on licensing: no more shareware, adware, whatever.
    206 +	+ Fix cursor positioning bug for C, S and c$ in an empty file.
    207 +1.74 -> 1.75 (08/22/96)
    208 +	+ Add French to the error message translations.
    209 +	+ Move the UNLICENSED message to the end of the message line.
    210 +	+ Fix bug where wide characters in a file name weren't calculated
    211 +	  correctly in the status message.
    212 +	+ Fix bug where cl_rename was called directly, by the ex shell code.
    213 +	+ Fix bug where splitting a screen resulting in a new screen at the
    214 +	  top of the display resulted in badly displayed status messages.
    215 +1.73 -> 1.74 (08/18/96)
    216 +	+ Fix bug where the status line wasn't redisplayed if the user ran
    217 +	  an ex command that trashed the screen.
    218 +	+ Fix bug where the long version of the status line wasn't displayed
    219 +	  when switching screens.
    220 +	+ Rework fast-path filename completion code to sort the entries, and
    221 +	  strip out . and .. by default.
    222 +	+ Fix bug where ex went to the first line instead of the last one when
    223 +	  reading in a file.
    224 +1.72 -> 1.73 (08/12/96)
    225 +	+ Do filename completion and some file expansion internally for speed.
    226 +	+ Fix CSCOPE_DIRS environmental variable support.
    227 +	+ Ex parser fix for global commands in script files.
    228 +	+ Add the O_PATH option, so you can specify a directory search path
    229 +	  for files.
    230 +	+ Make it possible to specify the database file to cscope, allowing
    231 +	  multiple databases in a single directory.
    232 +	+ Fix incremental search to overwrite erased characters so the user
    233 +	  can tell where they are on the colon-command line.
    234 +	+ Fix incremental search to restart the search if the user enters an
    235 +	  unescaped shell meta character.
    236 +1.71 -> 1.72 (07/12/96)
    237 +	+ Cscope fix: test for files newer than the database was reversed.
    238 +	+ Display "files to edit" message for rewind, next and initial screen.
    239 +	+ Fix a bug in the R command where it could fail if the user extended
    240 +	  the file.
    241 +	+ Fix a bug where text abbreviations could corrupt the line.
    242 +	+ Fix a bug where the windowname edit option couldn't be set before a
    243 +	  file was loaded into the edit buffer.
    244 +	+ Fix a bug where the system .exrc values weren't being overridden by
    245 +	  the user's $HOME .exrc values.
    246 +	+ Fix a bug in the filename completion code, where garbage characters
    247 +	  could be added to the colon command line.
    248 +	+ Fix bug where multiple edit sessions on a non-existent file could
    249 +	  all write the file without warning.
    250 +	+ Fix bug where screen update was incorrect if a character triggered
    251 +	  both a wrapmargin and showmatch condition.
    252 +	+ Fix bug in leftright scrolling where <CR> during text input didn't
    253 +	  return the cursor to the left margin.
    254 +	+ Rev the Perl interpreter code, new version from Sven Verdoolaege,
    255 +	  based on Perl 5.003.01.
    256 +	+ Fix bug in tags file pattern search introduced in 1.71.
    257 +1.70 -> 1.71 (07/01/96)
    258 +	+ Don't include <term.h> -- neither HPUX or Solaris can cope with it.
    259 +	+ Fix bug where ^M's in the original pattern were converted into new
    260 +	  lines in the file during substitution commands.
    261 +	+ Make window resize events separate from interrupts -- too many users
    262 +	  complained.
    263 +	+ Fix bug in first-character-is-null text input semantic.
    264 +	+ Rework search routines to take a length instead of a nul-terminated
    265 +	  string for a pattern.  This fixes a couple of bugs in searching, but
    266 +	  probably introduces new ones.
    267 +	+ Fix prompting the user after a write filter command, the way I did
    268 +	  it in 1.70 broke the display.
    269 +	+ Don't switch to the alternate xterm screen when entering the ex
    270 +	  text input commands from vi mode.
    271 +	+ Implement the Fg command, so can foreground a background screen into
    272 +	  a split screen.
    273 +	+ Change the fg command to match screen names using the last component
    274 +	  of the filename the full filename fails.
    275 +1.69 -> 1.70 (06/28/96)
    276 +	+ Change the ex read command to support named pipes.
    277 +	+ Copy the EXINIT/NEXINIT strings before executing their commands so
    278 +	  we don't step on the process environment.
    279 +	+ Don't do "line modification" reports for intermediate commands
    280 +	  executed from the vi colon command line, it screws up filter
    281 +	  reads, causing nvi to prompt for the user to continue.
    282 +	+ Add "smd" as an abbreviation for showmode: HP, ICL and SCO have it.
    283 +	+ Change nvi to always prompt the user after a write filter command.
    284 +	  This matches historic practice.
    285 +	+ Fix recovery information mailed to the user to reflect the program's
    286 +	  installed name.
    287 +	+ Change configuration script to not cache option information, e.g.,
    288 +	  --disable-curses.
    289 +	+ Fix a bug where the second character of the vi [[, ]] and ZZ
    290 +	  commands could start a command mapped sequence.
    291 +	+ Fix 3 write bugs: partial writes (3,$write), were clearing the
    292 +	  modified flag, full writes using line numbers (1,$write) were
    293 +	  not, and append historically never cleared the modified flag, and
    294 +	  we didn't get that right.
    295 +	+ Shorten the "more files to edit" message so it can gang on a single
    296 +	  line, lots of people have complained.  Add the number of files that
    297 +	  are left to edit, it's historic practice.
    298 +	+ Fix core dump where message catalogs collided with truncating the
    299 +	  write path.  Add a new write message so the string "appended" is
    300 +	  taken from a message catalog.
    301 +	+ Fix bug where an undo followed by '.' to repeat it wouldn't work
    302 +	  if no other repeatable commands had been entered.
    303 +	+ Fix core dump when resolution of input lines' autoindent characters
    304 +	  invalidated cached display information.
    305 +	+ Set the name of the X11 xterm icon/window to "xterm" when exiting,
    306 +	  if modified based on the windowname option.
    307 +	+ Include <term.h> if it exists, fixes portability problems on IRIX
    308 +	  systems.
    309 +1.68 -> 1.69 (06/17/96)
    310 +	+ Add the windowname edit option and code to change the icon/window
    311 +	  name for xterm's.
    312 +	+ Enhance the comment edit option to skip shell comments.
    313 +	+ Add conditional prototypes to replacement C library functions.
    314 +	+ Minor enhancements/reworking to Makefile.in, other build files.
    315 +	+ Fix bug in vi text input ^D processing, could result in cursor
    316 +	  warp to the beginning of the line.
    317 +	+ Fix leftright screen bug where the screen wasn't repainted when
    318 +	  being repainted from scratch.
    319 +	+ Update the Swedish and Dutch catalogs.
    320 +	+ Truncate paths in write commands if they don't fit on one line.
    321 +	+ Fix alternate screen bug where the screen flashed and output lost
    322 +	  when switching to/from the X11 xterm alternate screen.  Fix bug
    323 +	  where nvi switched into the alternate screen during filter-read
    324 +	  commands, which doesn't match historic practice.
    325 +	+ Minor relative cursor positioning change, make cursor position
    326 +	  changes from ex real and permanent.
    327 +1.67 -> 1.68 (06/09/96)
    328 +	+ Fix core dump when tagging out of a modified file.
    329 +1.66 -> 1.67 (06/09/96)
    330 +	+ Convert the license to adware.
    331 +	+ Leftright scrolling tweak, don't repaint the screen as often.
    332 +	+ Change so that search warning/error messages don't appear during an
    333 +	  incremental search.
    334 +	+ Cscope fix: test for files newer than the database was reversed.
    335 +	+ Don't display ex `welcome message' if in ex batch mode.
    336 +	+ Test for vsnprintf and snprintf separately, HP 10.10 has snprintf
    337 +	  but not vsnprintf.
    338 +	+ Reverse lookup order between LC_MESSAGES and LANG.
    339 +	+ Fix Tcl/Perl core dumps in common API code to get/set options.
    340 +	+ Fix R command -- it used a DB pinned page after discarding it.
    341 +	+ Minor fixes in multiple edit buffer message handling code.
    342 +	+ Fix yk command moving to shorter line core dump.
    343 +	+ Rework message handling to try and gang more messages onto a single
    344 +	  line.
    345 +1.65 -> 1.66 (05/18/96)
    346 +	+ Convert vi man page to historic -man macro package, and install it.
    347 +	+ Fix bug were !! on an empty line with a nonexistent command left the
    348 +	  cursor on the second character, not the first.
    349 +	+ Fix bug where line redisplay was wrong when a <tab> replaced a
    350 +	  previous <tab> in the line.
    351 +	+ Fix bug where D (d$) didn't reset the relative cursor position.
    352 +	+ Fix bug where yG incorrectly reset the relative cursor position.
    353 +	+ Fix bug where the window size couldn't be grown once it was shrunk.
    354 +	+ Fix bug where the extended edit option caused tag searches to fail.
    355 +	+ If multiple lines in the tags file with the same leading tag, build
    356 +	  a tags stack like the Cscope stack.  This is the obvious extension,
    357 +	  and the way that Larry McVoy's ctags program works.
    358 +	+ Send the appropriate TI/TE sequence in the curses screen whenever
    359 +	  entering ex/vi mode.  This means that :shell now shows the correct
    360 +	  screen when using xterm alternate screens.
    361 +	+ Rework the options display code to get five columns in an 80 column
    362 +	  screen.
    363 +	+ Interactive Unix V3.0 port -- mostly file name shortening, other
    364 +	  minor changes.  Only preliminary, more work will be necessary.
    365 +	+ Add debugging option to not read EXINIT/.exrc information.
    366 +	+ Fix bug where re_compile printed an error message to the screen
    367 +	  when the user entered [ to an incremental search.
    368 +	+ Turn off screen beeps when incremental search is failing.
    369 +	+ Fix bug where the iclower option didn't trigger an RE recompilation.
    370 +	+ Fix bug where -t into an already locked file forced the user to wait
    371 +	  as if a startup command had failed.
    372 +	+ LynxOS port -- mostly adding <sys/types.h> even though <sys/param.h>
    373 +	  was already included.
    374 +	+ Fix ex output bug, where it appeared as if an ex command was skipped
    375 +	  due to flags not being cleared in the vs_msg() routine.
    376 +	+ Fix core dump when global command tried to switch screens.
    377 +1.64 -> 1.65 (05/13/96)
    378 +	+ Fix cscope <blank>-matching pattern to use extended RE's, and bug
    379 +	  that kept cscope from finding patterns containing <blank>s.
    380 +	+ Fix core dumps in both leftright and folded screens when tabstops
    381 +	  edit option value was large, and tab characters occurred as the last
    382 +	  character in the logical screen.
    383 +	+ Fix core dump where the second screen of a folded line wasn't
    384 +	  displayed correctly.
    385 +	+ Fix incremental search to match the current location for strings
    386 +	  starting with \< patterns.
    387 +	+ Fix bug where margins were ignored during replay of text input.
    388 +	+ Fix bug where motion components to shorter lines could lose because
    389 +	  the relative motion flags weren't ever set.  This has been broken
    390 +	  forever, but the change almost certainly breaks something else -- I
    391 +	  have no idea what.
    392 +	+ Tags display: don't print the current entry separately, display
    393 +	  them all and add a trailing asterisk for the current one.
    394 +	+ Change the cscope add command to put the directory name through
    395 +	  standard file name expansion.
    396 +	+ Fix cscope use of buffers -- search commands weren't nul-terminated.
    397 +1.63 -> 1.64 (05/08/96)
    398 +	+ Add installation target to the Makefile.
    399 +	+ Add documentation on the new tags commands to the Vi Reference
    400 +	  Manual.
    401 +	+ Make the sidescroll edit option work again.
    402 +	+ Fix bug where messages output during startup by ex could be lost.
    403 +	+ Change ex/vi commands errors into beeps, unless the verbose edit
    404 +	  option is set -- there are too many macros that are expected to
    405 +	  eventually fail.  This matches historic practice.
    406 +	+ Truncate paths in initial vi screen if they won't fit on one line.
    407 +	+ Make cursor position after filter write match historic practice.
    408 +	+ Force the user to wait if there is output and the user is leaving
    409 +	  the screen for any reason -- don't permit further ex commands.
    410 +	+ Don't use a <newline> character to scroll the screen when exiting,
    411 +	  scroll in the vi screen before endwin() is called.
    412 +	+ Fix bug where the column number could be incorrect because the old
    413 +	  screen wasn't updated after a screen split.
    414 +	+ Fix ex print routine to correctly specify print flags.
    415 +	+ Make -g/-O a separate make/configuration option.
    416 +	+ Fix bug where ex/vi messages weren't being joined.
    417 +	+ Fix bug where termcap strings were free'd twice.
    418 +	+ Fix bug where TI/TE still weren't working -- I didn't put in the
    419 +	  translation strings for BSD style curses.
    420 +	+ Fix bug where I misspelled the iclower edit option as icloser.
    421 +1.62 -> 1.63 (04/29/96)
    422 +	+ Robustness and type/lint fixes for the Tcl interface code.
    423 +	+ Fix core dump if TERM wasn't set or terminal type was unknown.
    424 +	+ Fix bug where combining ex commands that did/did not require an
    425 +	  ex screen would overwrite the command with the want-to-continue
    426 +	  messsage.
    427 +	+ Fix bug where the screen was never resolved if the user continued
    428 +	  entering ex commands using the : character, but then backspaced
    429 +	  over the prompt to quit or tried to edit their colon command-line
    430 +	  history.
    431 +	+ Fix bug where cursor wasn't placed over the ^ placeholder character
    432 +	  when quoting using the literal-next character.
    433 +	+ Fix bug where nvi under BSD style curses wasn't sending TI/TE termcap
    434 +	  strings when suspending the process.
    435 +	+ Rename mic again, to iclower.
    436 +	+ Fix bug where 'z' commands trailing / or ? commands weren't being
    437 +	  executed.
    438 +	+ Change incremental search to leave the cursor at its last position
    439 +	  when searching for something that was never found.
    440 +	+ Fix bug where search-with-confirmation from vi mode didn't position
    441 +	  the cursor correctly after displaying the confirm message.
    442 +	+ Fix bug where the "search wrapped" message was dependent on the
    443 +	  verbose edit option, which doesn't match historic practice.  Change
    444 +	  search messages to be in inverse video.
    445 +	+ Fix bug where matched showmatch character wasn't being displayed
    446 +	  before the matching character was displayed.
    447 +	+ Another cursor update bug required a change to vs_paint().
    448 +	+ Fix bug were initial line offset was wrong for the first split screen
    449 +	  (symptom is very strange column numbers and blank first line).
    450 +	+ Create filename "argument" lists when creating new screens.
    451 +	+ Fix bug where globals with associated commands that included both
    452 +	  buffer execution and other commands could fail to execute the latter.
    453 +1.61 -> 1.62 (04/22/96)
    454 +	+ Rename the "searchci" edit option to be "mic".
    455 +	+ Fix memory corruption in global commands ending in searches.
    456 +	+ Fix text resolution bug, corrected the cursor based on the
    457 +	  first line input, not the last.
    458 +	+ Rework the readonly edit option to match historic practice.
    459 +	+ Fix several minor incremental search bugs; make incremental
    460 +	  searches work in maps.
    461 +	+ Fix long-line core dump, where an incorrect screen map could be
    462 +	  used.
    463 +1.60 -> 1.61 (04/12/96)
    464 +	+ The cursor now ends up on the FIRST character of the put text for
    465 +	  all versions of the vi put commands, regardless of the source
    466 +	  of the text.  This matches System III/V behavior and POSIX 1003.2.
    467 +	+ Fixed bug where showmatch messages were getting discarded.
    468 +	+ Minor Perl integration fixes.
    469 +	+ Integrate Cscope into the tags stack code -- major change.
    470 +	+ Fixed bug where ^T would drop core if returning to a temporary file.
    471 +	+ Changed vs_ routine to display ex output to replace tab characters
    472 +	  with spaces.
    473 +	+ Fix autoindent code to not back up past beginning of line when ^T
    474 +	  inserted into the middle of a line, i.e. offset != 0.
    475 +	+ Fix "notimeout" option, was being ignored, by a coding error.
    476 +	+ Fix showmatch code to never flash on a match if keys are waiting.
    477 +	+ Change the vi 'D' command to ignore any supplied count, matching
    478 +	  historic practice.
    479 +	+ Fix viusage for D, S, C and Y (the aliased vi commands).
    480 +	+ Fix the Perl5 configuration bug in the configuration script.
    481 +	+ Make file completion commands in empty lines work.
    482 +	+ Fix where the change to let vi use the default ex command structure
    483 +	  broke the ex specification of the script or source file name.
    484 +	+ Fix to free saved RE structures when screens exit.  This is a major
    485 +	  RE change, which fixed several bugs in the handling of saved/subst
    486 +	  RE's.  It's likely to have added new bugs, however.
    487 +	+ Add case-independent searching (the searchci edit option).
    488 +	+ Add incremental search (the searchincr edit option).
    489 +	+ Home the cursor when executing ex commands from vi.
    490 +1.59 -> 1.60 (03/29/96)
    491 +	+ Fix ":w >>" core dump, make that command match historic practice.
    492 +	+ Fix autoindent bug where the length of the line was incorrectly
    493 +	  calculated.
    494 +	+ Fix cursor bug where cursor could end up at the wrong place if the
    495 +	  movement keys were entered quickly enough.
    496 +	+ Change the read/write whirling indicator to appear only every 1/4
    497 +	  second, clean up the appearance.
    498 +	+ Don't change the options real values until underlying functions
    499 +	  have returned OK -- fix "set tabstop=0" core dump.
    500 +	+ Fix resizing on Sun's: use SA_INTERRUPT to interrupt read calls.
    501 +	+ Fix two forward mark command bugs: one where it wasn't setting the
    502 +	  "favorite cursor" position because of the refresh optimization,
    503 +	  and one where it didn't have VM_RCM_SET set in the command flags
    504 +	  for some reason.
    505 +	+ Fix a bug were the 's' command on top of a <tab> didn't correctly
    506 +	  copy the buffer.
    507 +	+ Make :exusage command work for commands having optional leading
    508 +	  capital letters, e.g. Next.
    509 +	+ Previous changes broke the inital-matching-prefix code in the key
    510 +	  mapping part of v_event_get -- fix it, and fix the infinite macro
    511 +	  interrupt code at the same time.
    512 +	+ Add "cedit" edit option, so colon command-line editing is optional.
    513 +	  Change filec/cedit so that you can set them to the same character,
    514 +	  and they do cedit if in column 1, and filec otherwise.
    515 +	+ Fix "source of non-existent file" core dump.
    516 +	+ Fix bug where functions keys specified in startup information were
    517 +	  never resolved/activated.
    518 +	+ Fix v_txt bug where could infinitely loop if <escape> triggered an
    519 +	  abbreviation expansion.
    520 +	+ Move version string into VERSION file, out of ex_version.c
    521 +1.58 -> 1.59
    522 +	+ Configuration changes, several minor bug fixes, including a few
    523 +	  core dumps.  No functional changes.
    524 +1.57 -> 1.58
    525 +	+ Fix the problem where colon command-line temporary files were
    526 +	  getting left in /tmp.
    527 +	+ Fix the configuration scripts to quit immediately if the Perl
    528 +	  or Tk/Tcl libraries are specified but not found.
    529 +	+ Several screen fixes -- the changes in 1.57 weren't as safe as
    530 +	  I thought.  More specifically, the refresh-only-if-waiting change
    531 +	  caused a lot of problems.  In general, fixing them should provide
    532 +	  even more speedup, but I'm nervous.
    533 +	+ Lots of changes in the configuration scripts, hopefully this is
    534 +	  just a first-round ordeal.
    535 +	+ Several other minor bug fixes.
    536 +1.56 -> 1.57
    537 +	+ Add <esc> hook to colon commands, so you can edit colon commands.
    538 +	+ Add Perl5 interpreter.
    539 +	+ Change shell expansion code to fail if it doesn't read at least
    540 +	  one non-blank character from the shell.  If the shell expansion
    541 +	  process fails, or if not at least one non-blank character, it
    542 +	  now displays an error message to the user.
    543 +	+ Rework the screen display so that it matches the historic vi screen
    544 +	  refreshes.
    545 +	+ Rework options processing: print/noprint are no longer cumulative,
    546 +	  provide more information to underlying edit options modules, move
    547 +	  O_MESG information into the screen specific code.
    548 +	+ Make file completion character settable.
    549 +	+ Rework terminal restart -- you can now use ":set term" to switch
    550 +	  terminal types.  This cleaned up screen resizing considerably.
    551 +	+ Character display fix, display \177 as ^?, not in hex/octal.
    552 +	+ Tag search bug fix, don't repeat search if successful.
    553 +	+ Replace sys_siglist[] use with private sigmsg() routine.
    554 +	+ Fix core dump if illegal screenId specified to Tcl routine.
    555 +	+ Add get/set mark interface to Tcl Interpreter interface.
    556 +	+ Fix core dump if file expansion code stressed (re: filec edit option)
    557 +	+ Fix bug where filter commands in empty files couldn't find line 0.
    558 +	+ Switch to GNU autoconf 2.7 for configuration, delete nvi/PORT.
    559 +	  Many random portability fixes.
    560 +1.55 -> 1.56 (11/26/95)
    561 +	+ Bug fix release -- generally available beta release.
    562 +1.54 -> 1.55 (11/18/95)
    563 +	+ Bug fix release.
    564 +	+ Integrate Tcl interpreter.
    565 +1.53 -> 1.54 (11/11/95)
    566 +	+ Bug fix release.  A major change in reworking the ex commands, when
    567 +	  called from the colon command line, to match historic practice, and
    568 +	  permit them to be entered repeatedly after ex has trashed the screen.
    569 +	+ Use restartable endwin() from System V curses to implement screen
    570 +	+ suspend.
    571 +1.52 -> 1.53 (10/29/95)
    572 +	+ Switch to using vendor's curses library for all ports.
    573 +	+ Back out the event driven version, leaving screen separation.
    574 +	+ User configuration of <escape> timeout (the escapetime edit option).
    575 +	+ Add Tcl/Tk screen support.
    576 +	+ Add file name completion (the filec edit option).
    577 +	+ Disallow access to outside applications (the secure edit option).
    578 +1.51 -> 1.52 (7/26/95)
    579 +	+ Minor cleanups, snapshotted for SMI.
    580 +1.50 -> 1.51 (7/05/95)
    581 +	+ Lots and lots of changes for event driven model, largely in moving
    582 +	  the boundary between the screen code and the editor up and down.
    583 +	  Private release for Rob Zimmermann @ Tartan and Bill Shannon @ SMI.
    584 +1.49 -> 1.50 Fri Jun  9 13:56:17 1995
    585 +	+ Minor bug fixes for stability.
    586 +	+ Convert to an event driven model, with the usual Nachos Supreme
    587 +	  layering that results.  This is a completely new version, nothing
    588 +	  done previously matters any more.
    589 +1.48 -> 1.49 Wed Mar  8 10:42:17 1995
    590 +	+ Changes in 1.46 broke ^A processing.
    591 +	+ Add :previous to split screen commands.
    592 +	+ Lots o' random bug fixes -- passes purify testing again.
    593 +1.47 -> 1.48 Thu Feb  9 18:13:29 1995
    594 +	+ Random bug fixes for 1.47.
    595 +	+ Move the FREF (file structure) list out of the screen and into
    596 +	  the global area.
    597 +	+ Change semantics to :E to more closely match :e -- ":E" joins
    598 +	  the current file, so ":E /tmp" is now the command to match the
    599 +	  historic ":split".
    600 +1.46 -> 1.47 Wed Feb  8 19:43:41 1995
    601 +	+ All ex commands (including visual and excluding global and v)
    602 +	  are now supported inside ex global commands.
    603 +	+ Rework the append/change/insert commands to match historic
    604 +	  practice for text appended to the ex command line, and inside
    605 +	  of ex global commands.
    606 +	+ Restructure to make single-line screens work.
    607 +	+ Restructure to create curses independent screen routines.
    608 +	+ Restructure to permit Edit, Next, and Tag routines to create new
    609 +	  screens on the fly.
    610 +	+ Change hexadecimal output to be \x## instead of 0x##.
    611 +	+ Change ex commands run from vi to stay in vi mode for as long as
    612 +	  possible, i.e. until ex modifies the screen outside of the editor.
    613 +1.45 -> 1.46 Tue Jan 24 10:22:27 1995
    614 +	+ Restructure to build as a library.
    615 +1.44 -> 1.45 Thu Jan 12 21:33:06 1995
    616 +	+ Fix relative cursor motion to handle folded lines.
    617 +	+ Recompile the search pattern if applicable edit options change.
    618 +	+ Change +/-c command ordering to match historic practice.
    619 +	+ Rework autoindent code to always resolve preceeding <blank>
    620 +	  characters when a ^T or ^D are entered.
    621 +	+ Add the print/noprint edit options, so can now specify if
    622 +	  a character is printable.
    623 +	+ Change ex to run in canonical mode.
    624 +	+ Fix ex text input to support the number edit option.
    625 +	+ Vi text input fix for the R command to correctly restore
    626 +	  characters entered and then backspaced over.
    627 +	+ Several vi increment command fixes.
    628 +1.43 -> 1.44
    629 +	+ Bug fix, vi was printing the last line number on the status line
    630 +	  at startup.  Change to execute commands at first line set, i.e.
    631 +	  "vi -t tag -c cmd" executes cmd at the tag line, not EOF.
    632 +1.42 -> 1.43 Sat Dec  3 13:11:32 1994
    633 +	+ Marks, SunOS signed comparison fix for 1.42.
    634 +1.41 -> 1.42 Fri Dec  2 20:08:16 1994
    635 +	+ Make autowrite require the file not be read-only.
    636 +	+ Make the ex insert command work in empty files.
    637 +	+ Tab expansion is no longer limited to values < 20 (which matches
    638 +	  historical practice).
    639 +	+ Simplify (and fix limit detection for) the # command.  It's no
    640 +	  longer possible to use the # command itself to repeat or modify
    641 +	  a previous # command, '.' is the only possibility.
    642 +	+ Lots more reworking of the ex addresses, putting ? and / into
    643 +	  the ex addressing code broke the world.
    644 +	+ Make the Put, Preserve and Print commands work (don't ask).
    645 +	+ Split stdout/stderr from shell expansions; stdout is expansion
    646 +	  text, stderr is entered on the message queue.
    647 +1.40 -> 1.41 Fri Nov 18 16:13:52 1994
    648 +	+ Addition of a port for AUX 3.1
    649 +	+ Addition of a message catalog for Russian.
    650 +	+ Make vi ? and / commands be true ex addresses (historic practice).
    651 +	+ Display the date first in vi -r recovery list.
    652 +1.39 -> 1.40 Mon Nov 14 10:46:56 1994
    653 +	+ Two bug fixes for 1.39; -r option and v_change core dump.
    654 +1.38 -> 1.39 Sun Nov 13 18:04:08 1994
    655 +	+ Ex substitution with confirmation now matches historic practice
    656 +	  (except that it still runs in raw mode, not cooked).
    657 +	+ Nvi now clears the screen before painting, if repainting the
    658 +	  entire screen.
    659 +	+ Fix final cursor position for put command entering text in a
    660 +	  single line.
    661 +	+ Change to break error message lines on the last <blank> in the
    662 +	  line.
    663 +	+ Always center the current line when returning to a previously
    664 +	  edited file or moving to a tag line that's not visible on the
    665 +	  screen.
    666 +	+ Change write of the current file using an explicit name or % to
    667 +	  match the semantics of :w<CR>, not :w file<CR>.
    668 +	+ Add command aliases to vi, and remap 6 historic commands to their
    669 +	  historic counterparts: D->d$, Y->y_, S->c_, C->c$, A->$a, I->^i.
    670 +	+ Match option display to historic practice; if boolean or numeric
    671 +	  options changed to default values, not displayed by default.
    672 +	  Nvi treats string options the same way, vi always displayed any
    673 +	  string option that was changed.
    674 +	+ Added lock edit option, if not set, no file locking is done.
    675 +	+ Rework ex to permit any ex command in the EXINIT variable or
    676 +	  exrc startup files.  This fixes the bug were `vi +100 file'
    677 +	  painted the screen and then moved to line 100 and repainted.
    678 +	  (Yanked to SCCS ID 9.1.)
    679 +	+ Bug fix: could report file modified more recently than it was
    680 +	  written, incorrectly.
    681 +	+ Search fix: historically, motions with deltas were not corrected
    682 +	  to the previous/next line based on the starting/stopping column.
    683 +	+ Addressing fixes: make trailing non-existent addresses work, change
    684 +	  % to be text substitution, not a unique address (to follow future
    685 +	  POSIX).
    686 +1.37 -> 1.38 Mon Oct 24 12:51:58 1994
    687 +	+ Scrolling fix; ^B can move to nonexistent lines.
    688 +	+ Fix to vi mapped commands; <escape> characters while already in
    689 +	  command mode did not historically cause the mapped characters to
    690 +	  be flushed.
    691 +	+ Add the backup edit option, automatically version edit files.
    692 +	+ Make it possible to edit files that db can't read, i.e. edit a
    693 +	  temporary file, with the correct file name.
    694 +	+ Only anchor the last line of the file to the bottom line of the
    695 +	  screen if there's half or less of a screen between the target
    696 +	  line and the end of the file.
    697 +	+ Fix wrapmargin text allocation bug.
    698 +	+ Fix ex put command to work in any empty file.
    699 +	+ Fix global command to handle move's to line 0 correctly.
    700 +	+ Regularize the yank cursor motions, several bug fixes for historic
    701 +	  practice.
    702 +	+ Fix N and n, when used as a motion command for the ! command,
    703 +	  repeat the last bang command instead of prompting for a new
    704 +	  one.
    705 +	+ Timeout maps beginning with <escape> quickly, instead of based
    706 +	  on the keytime option.
    707 +	+ Bug fix for wraplen option, wasn't triggered for input commands.
    708 +1.36 -> 1.37 Sun Oct  9 19:02:53 1994
    709 +	+ Change PORT directories to install patches before distribution.
    710 +	+ Fix ^A to set search direction and pattern for consistency.
    711 +	+ Fold the showdirty option into the showmode option.
    712 +	+ Ex addressing fix: change search offset and line arguments (e.g.
    713 +	  the copy command) to be ex addressing offsets, matching historic
    714 +	  practice.
    715 +	+ Ex addressing fix: support ^ as an offset/flag equivalent to -.
    716 +	+ Ex addressing fix: historically, any missing address defaulted to
    717 +	  dot, e.g. "4,,," was the same as ".,.".
    718 +	+ Ex addressing fix: historically, <blank> separated numbers were
    719 +	  additive, e.g. "3 5p" displayed line 8.
    720 +	+ Ex addressing fix: make ';' as a range delimiter match historic
    721 +	  practice.
    722 +	+ Change nvi to exit immediately if stdout isn't a terminal.
    723 +	+ Change alternate file name behavior to match historic practice,
    724 +	  make the :write command set the current file name.
    725 +	+ Text input fix; input keys from a map, with an associated count,
    726 +	  weren't historically affected by the wrapmargin value.
    727 +	+ Add wraplen option, same as wrapmargin, but from the left-hand
    728 +	  column, not the right.
    729 +	+ Make ex address .<number> be equivalent to .+<number>, i.e. the
    730 +	  '+' is understood; matches historic practice, and it's widely
    731 +	  documented for ed(1).
    732 +	+ Input mode ^V^J historically mapped into a single ^J.
    733 +	+ Minor catalog changes, fixes; don't use 's' to pluralize words.
    734 +1.35 -> 1.36 Thu Sep  8 08:40:25 1994
    735 +	+ Don't overwrite user's maps with standard (termcap) mappings.
    736 +	+ Make \ escape kill and erase characters in vi text input mode.
    737 +	+ Fix ^D autoindent bug by resolving leading <blank>s at ^D.
    738 +	+ Rework abbreviation tests (again!) to match historic practice.
    739 +	+ Change ^D/^U default scrolling value to be based on window option
    740 +	  value, not screen lines, correct scrolling option value, both to
    741 +	  match historic practice.  NOTE: System V does this differently!
    742 +1.34 -> 1.35 Wed Aug 31 19:20:15 1994
    743 +	+ Add the historic -l option.
    744 +	+ Message catalogs.
    745 +	+ Display global messages at each flush, just in case some are there.
    746 +	+ Fix global substitute code, `\\' wasn't handled correctly.
    747 +	+ Fix abbreviation code to use <blank>s as the preceding character.
    748 +	+ Fix ruler to display logical column, not physical column.
    749 +	+ Block signals when user issues :preserve command, so no race caused
    750 +	  by SIGHUP/SIGTERM.
    751 +1.33 -> 1.34 Wed Aug 17 14:37:32 1994 (PUBLICLY AVAILABLE VERSION)
    752 +	+ Back out sccsid string fix, it won't work on SunOS 4.1.
    753 +1.32 -> 1.33 Wed Aug 17 09:31:41 1994 (PUBLICLY AVAILABLE VERSION)
    754 +	+ Get back 5K of data space for the sccsid strings.
    755 +	+ Fix bug where cG fix in version 1.31 broke cw cursor positioning
    756 +	  when the change command extended the line.
    757 +	+ Fix core dump in map/seq code if character larger than 7 bits.
    758 +	+ Block signals when manipulating the SCR chains.
    759 +	+ Fix memory allocation for machines with multiple pointer sizes.
    760 +1.31 -> 1.32 Mon Aug 15 14:27:49 1994
    761 +	+ Turn off recno mmap call for Solaris 2.4/SunOS 5.4.
    762 +1.30 -> 1.31 Sun Aug 14 13:13:35 1994
    763 +	+ Fix bug were cG on the last line of a file wasn't done in line mode,
    764 +	  and where the cursor wasn't positioned correctly after exiting text
    765 +	  insert mode.
    766 +	+ Add termcap workaround to make function keys greater than 9 work
    767 +	  correctly (or fail if old-style termcap support).
    768 +	+ Change ex/vi to not flush mapped keys on error -- this is historic
    769 +	  practice, and people depended on it.
    770 +	+ Rework vi parser so that no command including a mapped key ever
    771 +	  becomes the '.' command, matching historic practice.
    772 +	+ Make <escape> cancellation in the vi parser match POSIX 1003.2.
    773 +	+ Fix curses bug where standout string was written for each standout
    774 +	  character, and where standout mode was never exited explicitly.
    775 +	  Fix bugs in curses SF/sf and SR/sr scrolling, as seen on Sun and
    776 +	  x86 consoles.
    777 +	+ The v/global commands execute the print command by default.
    778 +	+ The number option historically applies to ex as well as vi.
    779 +1.29 -> 1.30 Mon Aug  8 10:30:42 1994
    780 +	+ Make first read into a temporary set the file's name.
    781 +	+ Permit any key to continue scrolling or ex commands -- this
    782 +	  allows stacked colon commands, and matches historic practice.
    783 +	+ Don't output normal ! command commentary in ex silent mode.
    784 +	+ Allow +/- flags after substitute commands, make line (flag)
    785 +	  offsets from vi mode match historic practice.
    786 +	+ Return <eof> to ex immediately, even if preceded by spaces.  Rework
    787 +	  ex parser to do erase the prompt instead of depending on the print
    788 +	  routines to do it.  Minor fixes to the ex parser for display of
    789 +	  default and scrolling commands.  MORE EX PARSER CHANGES.
    790 +1.28 -> 1.29 Fri Aug  5 10:18:07 1994
    791 +	+ Make the abbreviated ex delete command work (:dele---###lll for
    792 +	  example, is historically legal.
    793 +	+ When autoprint fires, multiple flags may be set, use ex_print
    794 +	  directly instead of the stub routines.
    795 +	+ Change v/global commands to turn off autoprint while running.
    796 +	+ Minor changes to make the ! command display match historic output.
    797 +	+ Rework the ex parser to permit multiple command separators without
    798 +	  commands -- MAJOR CHANGE, likely to introduce all sorts of new bugs.
    799 +	+ Fix cd command to expand argument in the context of each element
    800 +	  of the cdpath option, make relative paths always relative to the
    801 +	  current directory.
    802 +	+ Rework write/quit cases for temporary files, so that user's don't
    803 +	  discard them accidentally.
    804 +	+ Check for window size changes when continuing after a suspend.
    805 +	+ Fix memory problem in svi_screen, used free'd memory.
    806 +	+ Change the ex change, insert, append commands to match historic
    807 +	  cursor positions if no data entered by the user.
    808 +	+ Change ex format flags (#, l, p) to affect future commands, not
    809 +	  just the current one, to match historic practice.
    810 +	+ Make the user's EOF character an additional scroll character in ex.
    811 +	+ Fix ex ^D scrolling to be the value of the scroll option, not half
    812 +	  the screen.
    813 +	+ Fix buffer execution to match historic practice -- bugs where the
    814 +	  '*' command didn't work, and @<carriage-return> didn't work.
    815 +	+ Fix doubled reporting of deleted lines in filters.
    816 +	+ Rework the % ` / ? ( ) N n { and ^A commands to always cut into
    817 +	  numeric buffers regardless of the location or length of the cut.
    818 +	  This matches historic practice.
    819 +	+ Fix the { command to check the current line if the cursor doesn't
    820 +	  start on the first character of the line.
    821 +	+ Do '!' expansion in the ex read command arguments, it's historic
    822 +	  practice.  In addition, it sets the last '!' command.
    823 +1.27 -> 1.28 Wed Jul 27 21:29:18 1994
    824 +	+ Add support for scrolling using the CS and SF/sf/SR/sr termcap
    825 +	  strings to the 4BSD curses.
    826 +	+ Rework of getkey() introduced a bug where command interrupt put
    827 +	  nvi into an infinite loop.
    828 +	+ Piping through a filter historically cut the replaced lines into
    829 +	  the default buffer, although not the numeric ones.
    830 +	+ Read of a filter and !! historically moved to the first nonblank
    831 +	  of the resulting cursor line (most of the time).
    832 +	+ Rework cursor motion flags, to support '!' as a motion command.
    833 +1.26 -> 1.27 Tue Jul 26 10:27:58 1994
    834 +	+ Add the meta option, to specify characters the shell will expand.
    835 +	+ Fix the read command to match historic practice, the white space
    836 +	  and bang characters weren't getting parsed correctly.
    837 +	+ Change SIGALRM handler to save and restore errno.
    838 +	+ Change SunOS include/compat.h to include <vfork.h> so that the
    839 +	  ex/filter.c code works again.
    840 +	+ Don't put lines deleted by the ex delete command into the numeric
    841 +	  buffers, matching historic practice.
    842 +	+ Fix; if appending to a buffer, default buffer historically only
    843 +	  references the appended text, not the resulting text.
    844 +	+ Support multiple, semi-colon separated search strings, and 'z'
    845 +	  commands after search strings.
    846 +	+ Make previous context mark setting match historic practice (see
    847 +	  docs/internals/context).
    848 +	+ Fix the set command to permit whitespace between the option and
    849 +	  the question mark, fix question marks in general.
    850 +	+ Fix bug where ex error messages could be accidentally preceded
    851 +	  by a single space.
    852 +	+ Fix bug where curses reorganization could lose screen specific
    853 +	  mappings as soon as any screen exited.
    854 +	+ Fix bug in paragraph code where invalid macros could be matched.
    855 +	  Make paragraph motions stop at formfeed (^L) characters.
    856 +	+ Change 'c' to match historic practice, it cut text into numeric
    857 +	  buffers.
    858 +1.25 -> 1.26 Tue Jul 19 17:46:24 1994
    859 +	+ Ignore SIGWINCH if the screen size is unchanged; SunOS systems
    860 +	  deliver one when a screen is uncovered.
    861 +	+ Fix: don't permit a command with a motion component to wrap due
    862 +	  to wrapscan and return to the original cursor position.
    863 +	+ Fix: ^E wasn't beeping when reaching the bottom of the file.
    864 +	+ Fix bg/fg bug where tmp file exiting caused a NULL dereference.
    865 +	+ Rework file locking code to use fcntl(2) explicitly.
    866 +	+ Fix bug in section code where invalid macros could be matched.
    867 +	+ Fix bug where line number reset by vi's Q command.
    868 +	+ Add explicit character mode designation to character mode buffers.
    869 +	+ Add <sys/ioctl.h> include to sex/sex_window.c, needed by NET/2
    870 +	  vintage systems.
    871 +	+ Change to always flush a character during suspend, 4BSD curses
    872 +	  has the optimization where it doesn't flush after a standend().
    873 +	+ Fix bug on OSF1 where <curses.h> changes the values of VERASE,
    874 +	  VKILL and VWERASE to incorrect ones.
    875 +	+ Fix bug where optarg used incorrectly in main.c.
    876 +	+ Block all signals when acting on a signal delivery.
    877 +	+ Fix recovery bug where RCV_EMAIL could fire even if there wasn't
    878 +	  a backing file; format recovery message.
    879 +1.24 -> 1.25 Sun Jul 17 14:33:38 1994
    880 +	+ Stop allowing keyboard suspends (^Z) in insert mode, it's hard
    881 +	  to get autowrite correct, and it's not historic practice.
    882 +	+ Fix z^, z+ to match historic practice.
    883 +	+ Bug in message handling, "vi +35 non-existent_file" lost the
    884 +	  status message because the "+35" pushed onto the stack erased
    885 +	  it.  For now, change so that messages aren't displayed if there
    886 +	  are keys waiting -- may need to add a "don't-erase" bit to the
    887 +	  character in the stack instead.
    888 +	+ Bug in svi_msgflush(), where error messages could come out in
    889 +	  normal video.
    890 +1.23 -> 1.24 Sat Jul 16 18:30:18 1994
    891 +	+ Fix core dump in exf.c, where editing a non-existent file and
    892 +	  exiting could cause already free'd memory to be free'd.
    893 +	+ Clean up numerous memory errors, courtesy of Purify.
    894 +	+ Change process wait code to fail if wait fails, and not attempt
    895 +	  to interpret the wait return information.
    896 +	+ Open recovery and DB files for writing as well as reading, System
    897 +	  V (fcntl) won't let you acquire LOCK_EX locks otherwise.
    898 +	+ Fix substitute bug where could malloc 0 bytes (AIX breaks).
    899 +	+ Permit the mapping of <carriage-return>, it's historic practice.
    900 +	+ Historic vi didn't eat <blank> characters before the force
    901 +	  flag, match historic practice.
    902 +	+ Bug in ex argument parsing, corrected for literal characters
    903 +	  twice.
    904 +	+ Delete screen specific maps when the screen closes.
    905 +	+ Move to the first non-<blank> in the line on startup; historic
    906 +	  practice.
    907 +	+ Change the ex visual command to move directly to a line if no
    908 +	  trailing 'z' command.
    909 +	+ Fix "[[" and "]]" to match historic practice (yet again...).
    910 +	+ Fix "yb" and "y{" commands to update the cursor correctly.
    911 +	+ Change "~<motion>" to match the yank cursor movement semantics
    912 +	  exactly.
    913 +	+ Move all of the curses related code into sex/svi -- major rework,
    914 +	  but should help in future ports.
    915 +	+ Fix bug in split code caused by new file naming code, where would
    916 +	  drop core when a split screen exited.
    917 +	+ Change svi_ex_write to do character display translation, so that
    918 +	  messages with file names in them are displayed correctly.
    919 +	+ Display the file name on split screens instead of a divider line.
    920 +	+ Fix move bug, wasn't copying lines before putting them.
    921 +	+ Fix bug were :n dropped core if no arguments supplied.
    922 +	+ Don't quote characters in executed buffer: "ifoo<esc>" should leave
    923 +	  insert mode after the buffer is executed.
    924 +	+ Tagpop and tagpush should set the absolute mark in case only moving
    925 +	  within a file.
    926 +	+ Skip leading whitespace characters before tags and cursor word
    927 +	  searches.
    928 +	+ Fix bug in ex_global where re_conv() was allocating the temporary
    929 +	  buffer and not freeing it.
    930 +1.22 -> 1.23: Wed Jun 29 19:22:33 1994
    931 +	+ New <sys/cdefs.h> required "inline" to change to "__inline"
    932 +	+ Fix System V curses code for new ^Z support.
    933 +	+ Fix off-by-one in the move code, avoid ":1,$mo$" with only one
    934 +	  line in the buffer.
    935 +	+ Line orientation of motion commands was remembered too long,
    936 +	  i.e.  '.' command could be incorrectly marked as line oriented.
    937 +	+ Move file modification time into EXF, so it's shared across
    938 +	  split screens.
    939 +	+ Put the prev[ious] command back in, people complained.
    940 +	+ Random fixes to next/prev semantics changed in 1.22.
    941 +	+ Historically vi doesn't only move to the last address if there's
    942 +	  ANYTHING after the addresses, e.g. ":3" moves to line 3, ":3|"
    943 +	  prints line 3.
    944 +1.21 -> 1.22: Mon Jun 27 11:01:41 1994
    945 +	+ Make the line between split screens inverse video again.
    946 +	+ Delete the prev[ious] command, it's not useful enough to keep.
    947 +	+ Rework :args/file name handling from scratch -- MAJOR CHANGE,
    948 +	  likely to introduce all sorts of new bugs.
    949 +	+ Fix RE bug where no subexpressions in the pattern but there were
    950 +	  subexpressions referenced in the replacement, e.g. "s/XXX/\1/g".
    951 +	+ Change recovery to not leave unmodified files around after a
    952 +	  crash, by using the owner 'x' bit on unmodified backup files.
    953 +	  MAJOR CHANGE, the system recovery script has to change!
    954 +	+ Change -r option to delete recovery.* files that reference non-
    955 +	  existent vi.* files.
    956 +	+ Rework recovery locking so that fcntl(2) locking will work.
    957 +	+ Fix append (upper-case) buffers, broken by cut fixes.
    958 +	+ Fix | to not set the absolute motion mark.
    959 +	+ Read $HOME/.exrc file on startup if the effective user ID is
    960 +	  root.  This makes running vi while su(1)'d work correctly.
    961 +	+ Use the full pathname of the file as the recovery name, not
    962 +	  just the last component.  Matches historic practice.
    963 +	+ Keep marks in empty files from being destroyed.
    964 +	+ Block all caught signals before calling the DB routines.
    965 +	+ Make the line change report match historic practice (yanked
    966 +	  lines were different than everything else).
    967 +	+ Add section on multiple screens to the reference manual.
    968 +	+ Display all messages at once, combine onto a single line if
    969 +	  possible.  Delete the trailing period from all messages.
    970 +1.20 -> 1.21: Thu May 19 12:21:58 1994
    971 +	+ Delete the -l flag from the recover mail.
    972 +	+ Send the user email if ex command :preserve executed, this matches
    973 +	  historic practice.  Lots of changes to the preserve and recovery
    974 +	  code, change preserve to snapshot files (again, historic practice).
    975 +	+ Make buffers match historic practice: "add logically stores text
    976 +	  into buffer a, buffer 1, and the unnamed buffer.
    977 +	+ Print <tab> characters as ^I on the colon command line if the
    978 +	  list option set.
    979 +	+ Adjust ^F and ^B scroll values in the presence of split screens
    980 +	  and small windows.
    981 +	+ Break msg* routines out from util.c into msg.c, start thinking
    982 +	  about message catalogs.
    983 +	+ Add tildeop set option, based on stevie's option of the same name.
    984 +	  Changes  the ~ command into "[count] ~ motion", i.e. ~ takes a
    985 +	  trailing motion.
    986 +	+ Chose NOT to match historic practice on cursor positioning after
    987 +	  consecutive undo commands on a single line; see vi/v_undo.c for
    988 +	  the comment.
    989 +	+ Add a one line cache so that multiple changes to the same line
    990 +	  are only counted once (e.g. "dl35p" changes one line, not 35).
    991 +	+ Rework signals some more.  Block file sync signals in vi routines
    992 +	  that interface to DB, so can sync the files at interrupt time.
    993 +	  Write up all of the signal handling arguments, see signal.c.
    994 +1.19 -> 1.20: Thu May  5 19:24:57 1994
    995 +	+ Return ^Z to synchronous handling.  See the dicussion in signal.c
    996 +	  and svi_screen.c:svi_curses_init().
    997 +	+ Fix bug where line change report was wrong in util.c:msg_rpt().
    998 +1.18 -> 1.19: Thu May  5 12:59:51 1994
    999 +	+ Block DSUSP so that ^Y isn't delivered at SIGTSTP.
   1000 +	+ Fix bug -- put into an empty file leaves the cursor at 1,0,
   1001 +	  not the first nonblank.
   1002 +	+ Fix bug were number of lines reported for the 'P' command was
   1003 +	  off-by-one.
   1004 +	+ Fix bug were 0^D wasn't being handled correctly.
   1005 +	+ Delete remnants of ^Z as a raw character.
   1006 +	+ Fix bug where if a map was an entire colon command, it may never
   1007 +	  have been displayed.
   1008 +	+ Final cursor position fixes for the vi T and t commands.
   1009 +	+ The ex :next command took an optional ex command as it's first
   1010 +	  argument similar to the :edit commands.  Match historic practice.
   1011 +1.17 -> 1.18: Wed May  4 13:57:10 1994
   1012 +	+ Rework curses information in the PORT/Makefile's.
   1013 +	+ Minor fixes to ^Z asynchronous code.
   1014 +1.16 -> 1.17: Wed May  4 11:15:56 1994
   1015 +	+ Make ex comment handling match historic practice.
   1016 +	+ Make ^Z work asynchronously, we can no longer use the SIGTSTP
   1017 +	  handler in the curses library.
   1018 +1.15 -> 1.16: Mon May  2 19:42:07 1994
   1019 +	+ Make the 'p' and 'P' commands support counts, i.e. "Y10p" works.
   1020 +	+ Make characters that map to themselves as the first part of the
   1021 +	  mapping work, it's historic practice.
   1022 +	+ Fix bug where "s/./\& /" discarded the space in the replacement
   1023 +	  string.
   1024 +	+ Add support for up/down cursor arrows in text input mode, rework
   1025 +	  left/right support to match industry practice.
   1026 +	+ Fix bug were enough character remapping could corrupt memory.
   1027 +	+ Delete O_REMAPMAX in favor of setting interrupts after N mapped
   1028 +	  characters without a read, delete the map counter per character.
   1029 +	  MAJOR CHANGE.  All of the interrupt signal handling has been
   1030 +	  reworked so that interrupts are always turned on instead of
   1031 +	  being turned on periodically, when an interruptible operation is
   1032 +	  pending.
   1033 +	+ Fix bug where vi wait() was interrupted by the recovery alarm.
   1034 +	+ Make +cmd's and initial commands execute with the current line
   1035 +	  set to the last line of the file.  This is historic practice.
   1036 +	+ Change "lock failed" error message to a file status message.
   1037 +	  It always fails over NFS, and making all NFS files readonly
   1038 +	  isn't going to fly.
   1039 +	+ Use the historic line number format, but check for overflow.
   1040 +	+ Fix bug where vi command parser ignored buffers specified as
   1041 +	  part of the motion command.
   1042 +	+ Make [@*]buffer commands on character mode buffers match historic
   1043 +	  practice.
   1044 +	+ Fix bug where the cmap/chf entries of the tty structure weren't
   1045 +	  being cleared when new characters were read.
   1046 +	+ Fix bug where the default command motion flags were being set
   1047 +	  when the command was a motion component.
   1048 +	+ Fix wrapmargin bug; if appending characters, and wrapmargin breaks
   1049 +	  the line, an additional space is eaten.
   1050 +1.14 -> 1.15: Fri Apr 29 07:44:57 1994
   1051 +	+ Make the ex delete command work in any empty file.
   1052 +	+ Fix bug where 't' command placed the cursor on the character
   1053 +	  instead of to its left.
   1054 +	+ ^D and ^U didn't set the scroll option value historically.
   1055 +	  Note, this change means that any user set value (e.g. 15^D)
   1056 +	  will be lost when splitting the screen, since the split code
   1057 +	  now resets the scroll value regardless.
   1058 +	+ Fix the ( command to set the absolute movement mark.
   1059 +	+ Only use TIOCGWINSZ for window information if SIGWINCH signal
   1060 +	  caught.
   1061 +	+ Delete the -l flag, and make -r work for multiple arguments.
   1062 +	  Add the ex "recover[!] file" command.
   1063 +	+ Switch into ex terminal mode and use the sex routines when
   1064 +	  append/change/insert called from vi mode.
   1065 +	+ Make ^F and ^B match historic practice.  This required a fairly
   1066 +	  extensive rework of the svi scrolling code.
   1067 +	+ Cursor positioning in H, M, L, G (first non-blank for 1G) wasn't
   1068 +	  being done correctly.  Delete the SETLFNB flag.  H, M, and L stay
   1069 +	  logical movements (SETNNB) and G always moves to the first nonblank.
   1070 +	+ System V uses "lines" and "cols", not "li" and "co", change as
   1071 +	  necessary.  Check termcap function returns for errors.
   1072 +	+ Fix `<character> command to do start/end of line correction,
   1073 +	  and to set line mode if starting and stopping at column 0.
   1074 +	+ Fix bug in delete code where dropped core if deleted in character
   1075 +	  mode to an empty line.  (Rework the delete code for efficiency.)
   1076 +	+ Give up on SunOS 4.1.X, and use "cc" instead of /usr/5bin/cc.
   1077 +	+ Protect ex_getline routine from interrupted system calls (if
   1078 +	  possible, set SA_RESTART on SIGALRM, too).
   1079 +	+ Fix leftright scrolling bug, when moving to a shorter line.
   1080 +	+ Do validity checking on the copy, move, t command target line
   1081 +	  numbers.
   1082 +	+ Change for System V % pattern broke trailing flags for empty
   1083 +	  replacement strings.
   1084 +	+ Fix bug when RCM flags retained in the saved dot structure.
   1085 +	+ Make the ex '=' command work for empty files.
   1086 +	+ Fix bug where special_key array was being free'd (it's no longer
   1087 +	  allocated).
   1088 +	+ Matches cut in line mode only if the starting cursor is at or
   1089 +	  before the first nonblank in its line, and the ending cursor is
   1090 +	  at or after the last nonblank in its line.
   1091 +	+ Add the :wn command, so you can write a file and switch to a new
   1092 +	  file in one command.
   1093 +	+ Allow only a single key as an argument to :viusage.
   1094 +	+ New movement code broke filter/paragraph operations in empty
   1095 +	  files ("!}date" in an empty file was dropping core).
   1096 +1.12 -> 1.14: Mon Apr 18 11:05:10 1994 (PUBLICLY AVAILABLE VERSION, 4.4BSD)
   1097 +	+ Fix FILE structure leakage in the ex filter code.
   1098 +	+ Rework suspend code for System V curses.  Nvi has to do the
   1099 +	  the work, there's no way to get curses to do it right.
   1100 +	+ Revert SunOS 4.1.X ports to the distributed curses.  There's
   1101 +	  a bug in Sun's implementation that we can't live with.
   1102 +	+ Quit immediately if row/column values are unreasonable.
   1103 +	+ Fix the function keys to match vi historic behavior.
   1104 +	+ Replace the echo/awk magic in the Makefile's with awk scripts.
   1105 +1.11 -> 1.12: Thu Apr 14 11:10:19 1994
   1106 +	+ Fix bug where only the first vi key was checked for validity.
   1107 +	+ Make 'R' continue to overwrite after a <carriage-return>.
   1108 +	+ Only display the "no recovery" message once.
   1109 +	+ Rework line backup code to restore the line to its previous
   1110 +	  condition.
   1111 +	+ Don't permit :q in a .exrc file or EXINIT variable.
   1112 +	+ Fix wrapscan option bug where forward searches become backward
   1113 +	  searches and do cursor correction accordingly.
   1114 +	+ Change "dd" to move the cursor to the first non-blank on the line.
   1115 +	+ Delete cursor attraction to the first non-blank, change non-blank
   1116 +	  motions to set the most attractive cursor position instead.
   1117 +	+ Fix 'r' substitute option to set the RE to the last RE, not the
   1118 +	  last substitute RE.
   1119 +	+ Fix 'c' and 'g' substitute options to always toggle, and fix
   1120 +	  edcompatible option to not reset them.
   1121 +	+ Display ex error messages in inverse video.
   1122 +	+ Fix errorbells option to match historic practice.
   1123 +	+ Delete fixed character display table in favor of table built based
   1124 +	  on the current locale.
   1125 +	+ Add ":set octal" option, that displays unknown characters as octal
   1126 +	  values instead of the default hexadecimal.
   1127 +	+ Make all command and text input modes interruptible.
   1128 +	+ Fix ex input mode to display error messages immediately, instead
   1129 +	  of waiting for the lines to be resolved.
   1130 +	+ Fix bug where vi calling append could overwrite the command.
   1131 +	+ Fix off-by-one in the ex print routine tab code.
   1132 +	+ Fix incorrect ^D test in vi text input routines.
   1133 +	+ Add autoindent support for ex text insert routines.
   1134 +	+ Add System V substitute command replacement pattern semantics,
   1135 +	  where '%' means the last replacement pattern.
   1136 +	+ Fix bug that \ didn't escape newlines in ex commands.
   1137 +	+ Regularize the names of special characters to CH_*.
   1138 +	+ Change hex insert character from ^Vx<hex_char> to ^X<hex_char>
   1139 +	+ Integrate System V style curses, so SunOS and Solaris ports can
   1140 +	  use the native curses implementation.
   1141 +1.10 -> 1.11: Thu Mar 24 16:07:45 EST 1994 (PUBLICLY AVAILABLE VERSION)
   1142 +	+ Change H, M, and L to set the absolute mark, historical practice.
   1143 +	+ Fix bug in stepping through multiple tags files.
   1144 +	+ Add "remapmax" option that turns off map counts so you can remap
   1145 +	  infinitely.  If it's off, term_key() can be interrupted from the
   1146 +	  keyboard, which will cause the buffers to flush.  I also dropped
   1147 +	  the default max number of remaps to 50.  (Only Dave Hitz's TM
   1148 +	  macros and maze appear to go over that limit.)
   1149 +	+ Change :mkexrc to not dump w{300,1200,9600}, lisp options.
   1150 +	+ Fix backward search within a line bug.
   1151 +	+ Change all the includes of "pathnames.h" to use <>'s so that the
   1152 +	  PORT versions can use -I. to replace it with their own versions.
   1153 +	+ Make reads and writes interruptible.  Rework code that enters and
   1154 +	  leaves ex for '!' and filter commands, rework all interrupt and
   1155 +	  timer code.
   1156 +	+ Fix core dump when user displayed option in .exrc file.
   1157 +	+ Fix bug where writing empty files didn't update the saved
   1158 +	  modification time.
   1159 +	+ Fix bug where /pattern/ addressing was always a backward search.
   1160 +	+ Fix bug triggered by autoindent of more than 32 characters, where
   1161 +	  nvi wasn't checking the right TEXT length.
   1162 +	+ Fix bug where joining only empty lines caused a core dump.
   1163 +1.09 -> 1.10: Sat Mar 19 15:40:29 EST 1994
   1164 +	+ Fix "set all" core dump.
   1165 +1.08 -> 1.09: Sat Mar 19 10:11:14 EST 1994
   1166 +	+ If the tag's file path is relative, and it doesn't exist, check
   1167 +	  relative to the tag file location.
   1168 +	+ Fix ~ command to free temporary buffer on error return.
   1169 +	+ Create vi.ref, a first cut at a reference document for vi.
   1170 +	  The manual page and the reference document only document the
   1171 +	  set options, so far.
   1172 +	+ Fix 1G bug not always going to the first non-blank.
   1173 +	+ Upgrade PORT/regex to release alpha3.4, from Henry Spencer.
   1174 +	+ Add MKS vi's "cdpath" option, supporting a cd search path.
   1175 +	+ Handle if search as a motion was discarded, i.e. "d/<erase>".
   1176 +	+ Change nvi to not create multiple recovery files if modifying
   1177 +	  a recovered file.
   1178 +	+ Decide to ignore that the cursor is before the '$' when inserting
   1179 +	  in list mode.  It's too hard to fix.
   1180 +1.07 -> 1.08: Wed Mar 16 07:37:36 EST 1994
   1181 +	+ Leftright and big line scrolling fixes.  This meant more changes
   1182 +	  to the screen display code, so there may be new problems.
   1183 +	+ Don't permit search-style addresses until a file has been read.
   1184 +	+ "c[Ww]" command incorrectly handled the "in whitespace" case.
   1185 +	+ Fix key space allocation bug triggered by cut/paste under SunOS.
   1186 +	+ Ex move command got the final cursor position wrong.
   1187 +	+ Delete "optimize option not implemented" message.
   1188 +	+ Make the literal-next character turn off mapping for the next
   1189 +	  character in text input mode.
   1190 +1.06 -> 1.07: Mon Mar 14 11:10:33 EST 1994
   1191 +	+ The "wire down" change in 1.05 broke ex command parsing, there
   1192 +	  wasn't a corresponding change to handle multiple K_VLNEXT chars.
   1193 +	+ Fix final position for vi's 't' command.
   1194 +1.05 -> 1.06: Sun Mar 13 16:12:52 EST 1994
   1195 +	+ Wire down ^D, ^H, ^W, and ^V, regardless of the user's termios
   1196 +	  values.
   1197 +	+ Add ^D as the ex scroll command.
   1198 +	+ Support ^Q as a literal-next character.
   1199 +	+ Rework abbreviations to be delimited by any !inword() character.
   1200 +	+ Add options description to the manual page.
   1201 +	+ Minor screen cache fix for svi_get.c.
   1202 +	+ Rework beautify option support to match historical practice.
   1203 +	+ Exit immediately if not reading from a tty and a command fails.
   1204 +	+ Default the SunOS 4.* ports to the distributed curses, not SMI's.
   1205 +1.04 -> 1.05: Thu Mar 24 16:07:45 EST 1994
   1206 +	+ Make cursor keys work in input mode.
   1207 +	+ Rework screen column code in vi curses screen.  MAJOR CHANGE --
   1208 +	  after this, we'll be debugging curses screen presentation from
   1209 +	  scratch.
   1210 +	+ Explode include files in vi.h into the source files.
   1211 +1.03 -> 1.04: Sun Mar  6 14:14:16 EST 1994
   1212 +	+ Make the ex move command keep the marks on the moved lines.
   1213 +	+ Change resize semantics so you can set the screen size to a
   1214 +	  specific value.  A couple of screen fixes for the resize code.
   1215 +	+ Fixes for foreground/background due to SIGWINCH.
   1216 +	+ Complete rework of all of vi's cursor movements.  The underlying
   1217 +	  assumption in the old code was that the starting cursor position
   1218 +	  was part of the range of lines cut or deleted.  The command
   1219 +	  "d[[" is an example where this isn't true.  Change it so that all
   1220 +	  motion component commands set the final cursor position separately
   1221 +	  from the range, as it can't be done correctly later.  This is a
   1222 +	  MAJOR CHANGE -- after this change, we'll be debugging the cursor
   1223 +	  positioning from scratch.
   1224 +	+ Rewrite the B, b, E, e commands to use vi's getc() interface
   1225 +	  instead of rolling their own.
   1226 +	+ Add a second MARK structure, LMARK, which is the larger mark
   1227 +	  needed by the logging and mark queue code.  Everything else uses
   1228 +	  the reworked MARK structure, which is simply a line/column pair.
   1229 +	+ Rework cut/delete to not expect 1-past-the-end in the range, but
   1230 +	  to act on text to the end of the range, inclusive.
   1231 +	+ Sync on write's, to force NFS to flush.
   1232 +1.01 -> 1.03: Sun Jan 23 17:50:35 EST 1994 (PUBLICLY AVAILABLE VERSION)
   1233 +	+ Tag stack fixes, was returning to the tag, not the position from
   1234 +	  which the user tagged.
   1235 +	+ Only use from the cursor to the end of the word in cursor word
   1236 +	  searches and tags.  (Matches historical vi behavior.)
   1237 +	+ Fix delete-last-line bug when line number option set.
   1238 +	+ Fix usage line for :split command.
   1239 +	+ If O_NUMBER set, long input lines would eventually fail, the column
   1240 +	  count for the second screen of long lines wasn't set correctly.
   1241 +	+ Fix for [[ reaching SOF with a column longer than the first line.
   1242 +	+ Fix for multiple error messages if no screen displayed.
   1243 +	+ Fix :read to set alternate file name as in historical practice.
   1244 +	+ Fix cut to rotate the numeric buffers if line mode flag set.
   1245 +1.00 -> 1.01: Wed Jan 12 13:37:18 EST 1994
   1246 +	+ Don't put cut items into numeric buffers if cutting less than
   1247 +	  parts of two lines.
   1248 +0.94 -> 1.00: Mon Jan 10 02:27:27 EST 1994
   1249 +	+ Read-ahead not there; BSD tty driver problem, SunOS curses
   1250 +	  problem.
   1251 +	+ Global command could error if it deleted the last line of
   1252 +	  the file.
   1253 +	+ Change '.' to only apply to the 'u' if entered immediately
   1254 +	  after the 'u' command.  "1pu.u.u. is still broken, but I
   1255 +	  expect that it's going to be sacrificed for multiple undo.
   1256 +	+ If backward motion on a command, now move to the point; get
   1257 +	  yank cursor positioning correct.
   1258 +	+ Rework cut buffers to match historic practice -- yank/delete
   1259 +	  numeric buffers redone sensibly, ignoring historic practice.
   1260 +0.92 -> 0.93: Mon Dec 20 19:52:14 EST 1993
   1261 +	+ Christos Zoulas reimplemented the script windows using pty's,
   1262 +	  which means that they now work reasonably.  The down side of
   1263 +	  this is that almost all ports other than 4.4BSD need to include
   1264 +	  two new files, login_tty.c and pty.c from the PORT/clib directory.
   1265 +	  I've added them to the Makefiles.
   1266 +	+ All calloc/malloc/realloc functions now cast their pointers, for
   1267 +	  SunOS -- there should be far fewer warning messages, during the
   1268 +	  build.  The remaining messages are where CHAR_T's meet char *'s,
   1269 +	  i.e. where 8-bit clean meets strcmp.
   1270 +	+ The user's argument list handling has been reworked so that there
   1271 +	  is always a single consistent position for use by :next, :prev and
   1272 +	  :rewind.
   1273 +	+ All of the historical options are now at least accepted, although
   1274 +	  not all of them are implemented.  (Edcompatible, hardtabs, lisp,
   1275 +	  optimize, redraw, and slowopen aren't implemented.)
   1276 +	+ The RE's have been reworked so that matches of length 0 are handled
   1277 +	  in the same way as vi used to handle them.
   1278 +	+ Several more mapping fixes and ex parser addressing fixes.
   1279 diff -Naur nvi-1.81.6.orig/nvi-1.79/docs/tutorial/vi.advanced nvi-1.81.6/nvi-1.79/docs/tutorial/vi.advanced
   1280 --- nvi-1.81.6.orig/nvi-1.79/docs/tutorial/vi.advanced	1970-01-01 01:00:00.000000000 +0100
   1281 +++ nvi-1.81.6/nvi-1.79/docs/tutorial/vi.advanced	2008-06-22 20:35:35.000000000 +0200
   1282 @@ -0,0 +1,1458 @@
   1283 +Section 26: Index to the rest of the tutorial
   1284 +
   1285 +The remainder of the tutorial can be perused at your leisure.  Simply find the
   1286 +topic of interest in the following list, and {/Section xx:/^M} to get to the
   1287 +appropriate section.  (Remember that ^M means the return key) 
   1288 +
   1289 +The material in the following sections is not necessarily in a bottom up
   1290 +order.  It should be fairly obvious that if a section mentions something with
   1291 +which you are not familiar, say, buffers, you might {/buffer/^M} followed by
   1292 +several {n} to do a keyword search of the file for more details on that item.
   1293 +Another point to remember is that commands are surrounded by curly-braces and
   1294 +can therefore be found rather easily.  To see where, say, the X command is
   1295 +used try {/{X}/^M}.  Subsequent {n} will show you other places the command was
   1296 +used.  We have tried to maintain the convention of placing the command letter
   1297 +surrounded by curly-braces on the section line where that command is
   1298 +mentioned.
   1299 +
   1300 +Finally, you should have enough 'savvy' at this point to be able to do your
   1301 +own experimentation with commands without too much hand-holding on the part of
   1302 +the tutorial.  Experimentation is the best way to learn the effects of the
   1303 +commands.
   1304 +
   1305 + Section      Topic - description
   1306 + -------      -------------------
   1307 +(Sections 1 through 25 are located in the file vi.beginner.)
   1308 +    1         introduction: {^F} {ZZ}
   1309 +    2         introduction (con't) and positioning: {^F} {^B}
   1310 +    3         introduction (con't) and positioning: {^F} {^B}
   1311 +    4         positioning: {^F} {^B} ^M (return key)
   1312 +    5         quitting: {:q!} ^M key
   1313 +    6         marking, cursor and screen positioning: {m} {G} {'} {z}
   1314 +    7         marking, cursor and screen positioning: {m} {G} {'} {z}
   1315 +    8         marking, cursor and screen positioning: {z} {m} {'}
   1316 +    9         marking and positioning: {m} {''}
   1317 +   10         line positioning: {^M} {-}
   1318 +   11         scrolling with {^M}
   1319 +   12         scrolling with {-} and screen adjustment {z}
   1320 +   13         notes on use of tutorial
   1321 +   14         other scrolling and postioning commands: {^E} {^Y} {^D} {^U}
   1322 +   15         searching: {/ .. /^M}
   1323 +   16         searching: {? .. ?^M} {n} (in search strings ^ $)
   1324 +   17         searching: \ and magic-characters in search strings
   1325 +   18         colon commands, exiting: {:} {ZZ}
   1326 +   19         screen positioning: {H} {M} {L}
   1327 +   20         character positioning: {w} {b} {0} {W} {B} {e} {E} {'} {`}
   1328 +   21         cursor positioning: {l} {k} {j} {h}
   1329 +   22         adding text: {i} {a} {I} {A} {o} {O} ^[ (escape key)
   1330 +   23         character manipulation: {f} {x} {X} {w} {l} {r} {R} {s} {S} {J}
   1331 +   24         undo: {u} {U}
   1332 +   25         review
   1333 +(The following sections are in this file.)
   1334 +   26         Index to the rest of the tutorial ******** YOU ARE HERE *******
   1335 +   27         discussion of repeat counts and the repeat command: {.}
   1336 +   28         more on low-level character motions: {t} {T} {|}
   1337 +   29         advanced correction operators: {d} {c}
   1338 +   30         updating the screen: {^R}
   1339 +   31         text buffers: {"}
   1340 +   32         rearranging and duplicating text: {p} {P} {y} {Y}
   1341 +   33         recovering lost lines
   1342 +   34         advanced file manipulation with vi
   1343 +   34.1          more than one file at a time: {:n}
   1344 +   34.2          reading files and command output: {:r}
   1345 +   34.3          invoking vi from within vi: {:e} {:vi}
   1346 +   34.4          escaping to a shell: {:sh} {:!}
   1347 +   34.5          writing parts of a file: {:w}
   1348 +   34.6          filtering portions of text: {!}
   1349 +   35         advanced searching: magic patterns 
   1350 +   36         advanced substitution: {:s} 
   1351 +   37         advanced line addressing: {:p} {:g} {:v}
   1352 +   38         higher level text objects and nroff: ( ) { } [[ ]]
   1353 +   39         more about inserting text
   1354 +   40         more on operators: {d} {c} {<} {>} {!} {=} {y}
   1355 +   41         abbreviations: {:ab}
   1356 +   42         vi's relationship with the ex editor: {:}
   1357 +   43         vi on hardcopy terminals and dumb terminals: open mode
   1358 +   44         options: {:set} {setenv EXINIT}
   1359 +   44.1          autoindent
   1360 +   44.2          autoprint
   1361 +   44.3          autowrite
   1362 +   44.4          beautify
   1363 +   44.5          directory
   1364 +   44.6          edcompatible
   1365 +   44.7          errorbells
   1366 +   44.8          hardtabs
   1367 +   44.9          ignorecase
   1368 +   44.10         lisp
   1369 +   44.11         list
   1370 +   44.12         magic
   1371 +   44.13         mesg                    
   1372 +   44.14         number
   1373 +   44.15         open
   1374 +   44.16         optimize
   1375 +   44.17         paragraphs
   1376 +   44.18         prompt
   1377 +   44.19         readonly
   1378 +   44.20         redraw
   1379 +   44.21         remap
   1380 +   44.22         report
   1381 +   44.23         scroll
   1382 +   44.24         sections
   1383 +   44.25         shell
   1384 +   44.26         shiftwidth
   1385 +   44.27         showmatch
   1386 +   44.28         slowopen
   1387 +   44.29         tabstop
   1388 +   44.30         tags
   1389 +   44.31         taglength
   1390 +   44.32         term
   1391 +   44.33         terse
   1392 +   44.34         timeout
   1393 +   44.35         ttytype
   1394 +   44.36         warn
   1395 +   44.37         window
   1396 +   44.38         wrapscan
   1397 +   44.39         wrapmargin
   1398 +   44.40         writeany
   1399 +   44.41         w300, w1200, w9600
   1400 +
   1401 +Section 27: repetition counts and the repeat command {.}
   1402 +
   1403 +Most vi commands will use a preceding count to affect their behavior in some
   1404 +way.  We have already seen how {3x} deletes three characters, and {22G} moves
   1405 +us to line 22 of the file.  For almost all of the commands, one can survive by
   1406 +thinking of these leading numbers as a 'repeat count' specifying that the
   1407 +command is to be repeated so many number of times.
   1408 +
   1409 +Other commands use the repeat count slightly differently, like the {G} command
   1410 +which use it as a line number.
   1411 +
   1412 +For example:
   1413 +
   1414 +{3^D} means scroll down in the file three lines.  Subsequent {^D} OR {^U} will
   1415 +scroll only three lines in their respective directions!
   1416 +
   1417 +{3z^M} says put line three of the file at the top of the screen, while {3z.}
   1418 +says put line three as close to the middle of the screen as possible.
   1419 +
   1420 +{50|} moves the cursor to column fifty in the current line.
   1421 +
   1422 +{3^F} says move forward 3 screenfulls.  This is a repetition count.  The
   1423 +documents advertise that {3^B} should move BACK three screenfulls, but I
   1424 +can't get it to work.
   1425 +
   1426 +Position the cursor on some text and try {3r.}.  This replaces three characters
   1427 +with '...'.  However, {3s.....^[} is the same as {3xi.....^[}.
   1428 +
   1429 +Try {10a+----^[}.
   1430 +
   1431 +A very useful instance of a repetition count is one given to the '.' command,
   1432 +which repeats the last 'change' command.  If you {dw} and then {3.}, you will
   1433 +delete first one and then three words.  You can then delete two more words with
   1434 +{2.}.  If you {3dw}, you will delete three words.  A subsequent {.} will delete
   1435 +three more words.  But a subsequent {2.} will delete only two words, not three
   1436 +times two words.
   1437 +
   1438 +Caveat: The author has noticed that any repetition count with {^B} will NOT
   1439 +work: indeed, if you are at the end of your file and try {3^B} sufficiently
   1440 +often, the editor will hang you in an infinite loop.  Please don't try it:
   1441 +take my word for it.
   1442 +
   1443 +Section 28: {t} {T} {|}
   1444 +
   1445 +Position the cursor on line 13 below:
   1446 +
   1447 +Line 13: Four score and seven years ago, our forefathers brought ...
   1448 +
   1449 +Note that {fv} moves the cursor on/over the 'v' in 'seven'.  Do a {0} to return
   1450 +to the beginning of the line and try a {tv}.  The cursor is now on/over the
   1451 +first 'e' in 'seven'.  The {f} command finds the next occurrence of the
   1452 +specified letter and moves the cursor to it.  The {t} command finds the
   1453 +specified letter and moves the cursor to the character immediately preceding
   1454 +it.  {T} searches backwards, as does {F}.
   1455 +
   1456 +Now try {60|}: the cursor is now on the 'o' in 'brought', which is the
   1457 +sixtieth character on the line.
   1458 +
   1459 +Section 29: {d} {c}
   1460 +
   1461 +Due to their complexity we have delayed discussion of two of the most powerful
   1462 +operators in vi until now.  Effective use of these operators requires more
   1463 +explanation than was deemed appropriate for the first half of the tutorial.
   1464 +
   1465 +{d} and {c} are called operators instead of commands because they consist of
   1466 +three parts: a count specification or a buffer specification (see section
   1467 +#BUFFERS), the {d} or {c}, and the object or range description.  We will not
   1468 +discuss buffers at this stage, but will limit ourselves to count
   1469 +specifications.  Examples speak louder than words: position the cursor at the
   1470 +beginning of line 14:
   1471 +
   1472 +Line 14: Euclid alone has looked on beauty bear.
   1473 +
   1474 +Obviously, there is something wrong with this quotation.  Type {2fb} to
   1475 +position the cursor on the 'b' of 'bear'.  Now, type {cwbare^[}
   1476 +and observe the results.  The {cw} specifies that the change command {c} is to
   1477 +operate on a word object.  More accurately, it specifies that the range of the
   1478 +change command includes the next word.
   1479 +
   1480 +Position the cursor on the period in Line 14. (one way is to use {f.})
   1481 +Now, type {cbbeast^[}.  This specifies the range of the change command to be the
   1482 +previous word (the 'b' reminiscent of the {b} command).  If we had wished to
   1483 +delete the word rather than change it, we would have used the {d} operator,
   1484 +rather than the {c} operator.
   1485 +
   1486 +Position the cursor at the beginning of the line with {0}.  Type
   1487 +{d/look/^M}.  The search string specified the range of the delete.
   1488 +Everything UP TO the word 'looking' was deleted from the line.
   1489 +
   1490 +In general, almost any command that would move the cursor will specify a range
   1491 +for these commands.  The most confusing exception to this rule is when {dd} or
   1492 +{cc} is entered: they refer to the whole line.  Following is a summary of the
   1493 +suffixes (suffices? suffici?) and the ranges they specify:
   1494 +
   1495 +    suffix        will delete{d}/change{c}
   1496 +    ------        ------------------------
   1497 +      ^[            cancels the command
   1498 +      w             the word to the right of the cursor
   1499 +      W             ditto, but ignoring punctuation
   1500 +      b             the word to the left of the cursor
   1501 +      B             ditto, but ignoring punctuation
   1502 +      e             see below.
   1503 +      E               ditto
   1504 +      (space)       a character
   1505 +      $             to the end of the line
   1506 +      ^             to the beginning of the line
   1507 +      / .. /        up to, but not including, the string
   1508 +      ? .. ?        back to and including the string
   1509 +      fc            up to and including the occurrence of c 
   1510 +      Fc            back to and including the occurrence of c
   1511 +      tc            up to but not including the occurrence of c
   1512 +      Tc            back to but not including the occurrence of c
   1513 +      ^M            TWO lines (that's right: two)
   1514 +      (number)^M    that many lines plus one
   1515 +      (number)G     up to and including line (number)
   1516 +      (             the previous sentence if you are at the beginning of
   1517 +                    the current sentence, or the current sentence up to where 
   1518 +                    you are if you are not at the beginning of the current 
   1519 +                    sentence.  Here, 'sentence' refers to the intuitive
   1520 +                    notion of an English sentence, ending with '!', '?',
   1521 +                    or '.' and followed by an end of line or two spaces.
   1522 +      )             the rest of the current sentence
   1523 +      {             analogous to '(', but in reference to paragraphs:
   1524 +                    sections of text surrounded by blank lines
   1525 +      }             analogous to ')', but in reference to paragraphs
   1526 +      [[            analogous to '(', but in reference to sections
   1527 +      ]]            analogous to ')', but in reference to sections
   1528 +      H             the first line on the screen
   1529 +      M             the middle line on the screen
   1530 +      L             the last line on the screen
   1531 +      3L            through the third line from the bottom of the screen
   1532 +      ^F            forward a screenful
   1533 +      ^B            backward a screenful
   1534 +      :
   1535 +      :  etc. etc. etc.
   1536 +
   1537 +This list is not exhaustive, but it should be sufficient to get the idea
   1538 +across: after the {c} or {d} operator, you can specify a range with another
   1539 +move-the-cursor command, and that is the region of text over which the command
   1540 +will be effective.
   1541 +
   1542 +Section 30: updating the screen {^R}
   1543 +
   1544 +Vi tries to be very intelligent about the type of terminal you are working on
   1545 +and tries to use the in-terminal computing power (if any) of your terminal.
   1546 +Also if the terminal is running at a low baud rate (say 1200 or below), vi sets
   1547 +various parameters to make things easier for you.  For example, if you were
   1548 +running on a 300 baud terminal (that's 30 characters per second transmission
   1549 +rate) not all 24 lines of the screen would be used by vi.  In addition, there
   1550 +is a large portion of the editor keeping track of what your screen currently
   1551 +looks like, and what it would look like after a command has been executed.  Vi
   1552 +then compares the two, and updates only those portions of the screen that have
   1553 +changed.
   1554 +
   1555 +Furthermore, some of you may have noticed (it depends on your terminal) that 
   1556 +deleting lines or changing large portions of text may leave some lines on the 
   1557 +screen looking like: 
   1558 +@ 
   1559 +meaning that this line of the screen does not correspond to any line in your
   1560 +file. It would cost more to update the line than to leave it blank for the
   1561 +moment.  If you would like to see your screen fully up-to-date with the
   1562 +contents of your file, type {^R}.
   1563 +
   1564 +To see it in action, delete several lines with {5dd}, type {^R}, and then type
   1565 +{u} to get the lines back.
   1566 +
   1567 +Here is as good a place as any to mention that if the editor is displaying the
   1568 +end of your file, there may be lines on the screen that look like: 
   1569 +~ 
   1570 +indicating that that screen line would not be affected by {^R}.  These lines
   1571 +simply indicate the end of the file.
   1572 +
   1573 +Section 31: text buffers {"}
   1574 +
   1575 +Vi gives you the ability to store text away in "buffers".  This feature is very
   1576 +convenient for moving text around in your file.  There are a total of thirty-
   1577 +five buffers available in vi.  There is the "unnamed" buffer that is used by all
   1578 +commands that delete text, including the change operator {c}, the substitute
   1579 +and replace commands {s} and {r}, as well as the delete operator {d} and delete
   1580 +commands {x} and {X}.  This buffer is filled each time any of these commands
   1581 +are used. However, the undo command {u} has no effect on the unnamed buffer.
   1582 +
   1583 +There are twenty-six buffers named 'a' through 'z' which are available for the
   1584 +user.  If the name of the buffer is capitalized, then the buffer is not
   1585 +overwritten but appended to.  For example, the command {"qdd} will delete one
   1586 +line and store that line in the 'q' buffer, destroying the previous contents of
   1587 +the buffer.  However, {"Qdd} will delete one line of text and append that line
   1588 +to the current contents of the 'q' buffer.
   1589 +
   1590 +Finally, there are nine buffers named '1' through '9' in which the last nine
   1591 +deletes are stored.  Buffer 1 is the default buffer for the modify commands and
   1592 +is sometimes called the unnamed buffer.
   1593 +
   1594 +To reference a specific buffer, use the double-quote command {"} followed by
   1595 +the name of the buffer.  The next two sections show how buffers can be used to
   1596 +advantage.
   1597 +
   1598 +Section 32: rearranging and duplicating text: {y} {Y} {p} {P}
   1599 +
   1600 +Position yourself on line 15 below and {z^M}:
   1601 +
   1602 +Line 15: A tree as lovely as a poem ...
   1603 +Line 16: I think that I shall never see
   1604 +
   1605 +Type {dd}.  Line 15 has disappeared and been replaced with the empty line (one
   1606 +with the single character @ on it) or (again depending on your terminal) Line
   1607 +16 has moved up and taken its place.  We could recover Line 15 with an undo
   1608 +{u} but that would simply return it to its original location.  Obviously, the
   1609 +two lines are reversed, so we want to put line 15 AFTER line 16.  This is
   1610 +simply done with the put command {p}, which you should type now.  What has
   1611 +happened is that {dd} put Line 15 into the unnamed buffer, and the {p} command
   1612 +retrieved the line from the unnamed buffer.
   1613 +
   1614 +Now type {u} and observe that Line 15 disappears again (the put was undone
   1615 +without affecting the unnamed buffer).  Type {P} and see that the capital {P}
   1616 +puts the line BEFORE the cursor.
   1617 +
   1618 +To get Line 15 where it belongs again type {dd}{p}.
   1619 +
   1620 +Also in Line 15 note that the words 'tree' and 'poem' are reversed.  Using the
   1621 +unnamed buffer again: {ft}{dw}{ma}{fp}{P}{w}{dw}{`aP} will set things aright 
   1622 +(note the use of the reverse quote).
   1623 +
   1624 +The put commands {p} and {P} do not affect the contents of the buffer.
   1625 +Therefore, multiple {p} or {P} will put multiple copies of the unnamed buffer
   1626 +into your file.
   1627 +
   1628 +Experiment with {d} and {p} on words, paragraphs, etc.  Whatever {d}
   1629 +deletes, {p} can put.
   1630 +
   1631 +Position the cursor on Line 17 and {z^M}:
   1632 +
   1633 +Line 17: interest apple cat elephant boy dog girl hay farmer
   1634 +
   1635 +Our task is to alphabetize the words on line 17.  With the named buffers (and a
   1636 +contrived example) it is quite easy:
   1637 +
   1638 +{"idw}{"adw}{"cdw}{"edw}{"bdw}{"ddw}{"gdw}{"hdw}{"fdw}
   1639 +
   1640 +stores each of the words in the named buffer corresponding to the first letter
   1641 +of each of the words ('interest' goes in buffer "i, 'apple' goes in buffer "a,
   1642 +etc.).  Now to put the words in order type:
   1643 +
   1644 +{"ap$}{"bp$}{"cp$}{"dp$}{"ep$}{"fp$}{"gp$}{"hp$}{"ip$}
   1645 +
   1646 +Notice that, because 'farmer' was at the end of the line, {dw} did not include
   1647 +a space after it, and that, therefore, there is no space between 'farmer' and
   1648 +'girl'.  This is corrected with {Fg}{i ^[}.
   1649 +
   1650 +This example could have been done just as easily with lines as with
   1651 +words.
   1652 +
   1653 +You do not have to delete the text in order to put it into a buffer.  If all
   1654 +you wish to do is to copy the text somewhere else, don't use {d}, rather use
   1655 +the yank commands {y} or {Y}.  {y} is like {d} and {c} - an operator rather
   1656 +than a command.  It, too, takes a buffer specification and a range
   1657 +specification.  Therefore, instead of {dw}{P} to load the unnamed buffer with a
   1658 +word without deleting the word, use {yw} (yank a word).
   1659 +
   1660 +{Y} is designed yank lines, and not arbitrary ranges.  That is, {Y} is
   1661 +equivalent to {yy} (remember that operators doubled means the current line),
   1662 +and {3Y} is equivalent to {3yy}.
   1663 +
   1664 +If the text you yank or modify forms a part of a line, or is an object such as
   1665 +a sentence which partially spans more than one line, then when you put the text
   1666 +back, it will be placed after the cursor (or before if you use {P}).  If the
   1667 +yanked text forms whole lines, they will be put back as whole lines, without
   1668 +changing the current line.  In this case, the put acts much like the {o} or {O}
   1669 +command.
   1670 +
   1671 +The named buffers "a through "z are not affected by changing edit files.
   1672 +However, the unnamed buffer is lost when you change files, so to move text from
   1673 +one file to another you should use a named buffer.
   1674 +
   1675 +Section 33: recovering lost lines
   1676 +
   1677 +Vi also keeps track of the last nine deletes, whether you ask for it or not.
   1678 +This is very convenient if you would like to recover some text that was
   1679 +accidentally deleted or modified.  Position the cursor on line 18 following,
   1680 +and {z^M}.
   1681 +
   1682 +
   1683 +Line 18: line 1
   1684 +Line 19: line 2
   1685 +Line 20: line 3
   1686 +Line 21: line 4
   1687 +Line 22: line 5
   1688 +Line 23: line 6
   1689 +Line 24: line 7
   1690 +Line 25: line 8
   1691 +Line 26: line 9
   1692 +Type {dd} nine times: now don't cheat with {9dd}!  That is totally different.
   1693 +
   1694 +The command {"1p} will retrieve the last delete.  Furthermore, when the
   1695 +numbered buffers are used, the repeat-command command {.} will increment the
   1696 +buffer numbers before executing, so that subsequent {.} will recover all nine
   1697 +of the deleted lines, albeit in reverse order.  If you would like to review the
   1698 +last nine deletes without affecting the buffers or your file, do an undo {u}
   1699 +after each put {p} and {.}:
   1700 +
   1701 +{"1p}{u}{.}{u}{.}{u}{.}{u}{.}{u}{.}{u}{.}{u}{.}{u}{.}
   1702 +
   1703 +will show you all the buffers and leave them and your file intact.
   1704 +
   1705 +If you had cheated above and deleted the nine lines with {9dd}, all nine lines
   1706 +would have been stored in both the unnamed buffer and in buffer number 1. 
   1707 +(Obviously, buffer number 1 IS the unnamed buffer and is just the default
   1708 +buffer for the modify commands.)
   1709 +
   1710 +Section 34: advanced file manipulation: {:r} {:e} {:n} {:w} {!} {:!}
   1711 +
   1712 +We've already looked at writing out the file you are editing with the
   1713 +{:w} command.  Now let's look at some other vi commands to make editing
   1714 +more efficient.
   1715 +
   1716 +Section 34.1: more than one file at a time {:n} {:args}
   1717 +
   1718 +Many times you will want to edit more than one file in an editing session.
   1719 +Instead of entering vi and editing the first file, exiting, entering vi and
   1720 +editing the second, etc., vi will allow you to specify ALL files that you wish
   1721 +to edit on the invocation line.  Therefore, if you wanted to edit file1 and
   1722 +file2:
   1723 +
   1724 +% vi file1 file2
   1725 +
   1726 +will set up file1 for editing.  When you are done editing file one, write it
   1727 +out {:w^M} and then type {:n^M} to get the next file on the list.  On large
   1728 +programming projects with many source files, it is often convenient just to
   1729 +specify all source files with, say:
   1730 +
   1731 +% vi *.c
   1732 +
   1733 +If {:n^M} brings in a file that does not need any editing, another {:n^M}
   1734 +will bring in the next file.
   1735 +
   1736 +If you have made changes to the first file, but decide to discard these changes
   1737 +and proceed to the next file, {:n!^M} forces the editor to discard the current
   1738 +contents of the editor.
   1739 +
   1740 +You can specify a new list of files after {:n}; e.g., {:n f1 f2 f3^M}.  This
   1741 +will replace the current list of files (if any).
   1742 +
   1743 +You can see the current list of files being edited with {:args^M}.
   1744 +
   1745 +Section 34.2: reading files and command output: {:r}
   1746 +
   1747 +Typing {:r fname^M} will read the contents of file fname into the editor and
   1748 +put the contents AFTER the cursor line.
   1749 +
   1750 +Typing {:r !cmd^M} will read the output of the command cmd and place that
   1751 +output after the cursor line.
   1752 +
   1753 +Section 34.3: invoking vi from within vi: {:e} {:vi}
   1754 +
   1755 +To edit another file not mentioned on the invocation line, type {:e filename^M}
   1756 +or {:vi filename^M}.  If you wish to discard the changes to the current file,
   1757 +use the exclamation point after the command, e.g. {:e! filename^M}.
   1758 +
   1759 +Section 34.4: escaping to a shell: {:sh} {:!} {^Z}
   1760 +
   1761 +Occasionally, it is useful to interrupt the current editing session to perform
   1762 +a UNIX task.  However, there is no need to write the current file out, exit
   1763 +the editor, perform the task, and then reinvoke the editor on the same file.
   1764 +One thing to do is to spin off another process.  If there are several UNIX
   1765 +commands you will need to execute, simply create another shell with {:sh^M}.
   1766 +At this point, the editor is put to sleep and will be reawakened when you log
   1767 +out of the shell.
   1768 +
   1769 +If it is a single command that you want to execute, type {:!cmd^M}, where cmd
   1770 +is the command that you wish to run.  The output of the command will come to
   1771 +the terminal as normal, and will not be made part of your file.  The message
   1772 +"[Hit return to continue]" will be displayed by vi after the command is
   1773 +finished.  Hitting return will then repaint the screen.  Typing another
   1774 +{:!cmd^M} at this point is also acceptable.
   1775 +
   1776 +However, there is a quicker, easier way: type {^Z}.  Now this is a little
   1777 +tricky, but hang in there.  When you logged into UNIX, the first program you
   1778 +began communicating with was a program that is called a "shell" (i.e. it 'lays
   1779 +over' the operating system protecting you from it, sort of like a considerate
   1780 +porcupine).  When you got your first prompt on the terminal (probably a '%'
   1781 +character) this was the shell telling you to type your first command.  When
   1782 +you typed {vi filename} for some file, the shell did not go away, it just went
   1783 +to sleep.  The shell is now the parent of vi.  When you type {^Z} the editor
   1784 +goes to sleep, the shell wakes up and says "you rang?" in the form of another
   1785 +prompt (probably '%').  At this point you are talking to the shell again and
   1786 +you can do anything that you could before including edit another file!  (The
   1787 +only thing you can't do is log out: you will get the message "There are
   1788 +stopped jobs.")
   1789 +
   1790 +When your business with the shell is done, type {fg} for 'foreground' and the
   1791 +last process which you ^Z'd out of will be reawakened and the shell will go
   1792 +back to sleep.  I will refer you to the documentation for the Berkeley shell
   1793 +'csh' for more information on this useful capability.
   1794 +
   1795 +Section 34.5: writing parts of a file: {:w}
   1796 +
   1797 +The {:w} command will accept a range specifier that will then write only a
   1798 +selected range of lines to a file.  To write this section to a file, position
   1799 +the cursor on the section line (e.g. {/^Section 34.5:/^M}) and {z^M}.  Now type
   1800 +{^G} to find out the line number (it will be something like "line 513").  Now
   1801 +{/^Section 34.6:/-1^M} to find the last line of this section, and {^G} to find
   1802 +its line number (it will be something like 542).  To write out this section of
   1803 +text by itself to a separate file which we will call "sepfile", type
   1804 +{:510,542w sepfile^M}.  If sepfile already exists, you will have to use the
   1805 +exclamation point: {:1147,1168w! sepfile^M} or write to a different, non-
   1806 +existent file.
   1807 +
   1808 +{:!cat sepfile^M} will display the file just written, and it should be the
   1809 +contents of this section.
   1810 +
   1811 +There is an alternate method of determining the line numbers for the write.
   1812 +{:set number^M} will repaint the screen with each line numbered.  When the file
   1813 +is written and the numbers no longer needed, {:set nonumber^M} will remove the
   1814 +numbers, and {^R} will adjust the screen.
   1815 +
   1816 +Or, if you remember your earlier lessons about marking lines of text,
   1817 +mark the beginning and ending lines.  Suppose we had used {ma} to mark the
   1818 +first line of the section and {mb} to mark the last.  Then the command
   1819 +{:'a,'bw sepfile^M} will write the section into "sepfile".  In general,
   1820 +you can replace a line number with the 'name' of a marked line (a single-quote
   1821 +followed by the letter used to mark the line)
   1822 +
   1823 +
   1824 +Section 34.6: filtering portions of text: {!}
   1825 +
   1826 +{!} is an operator like {c} and {d}.  That is, it consists of a repetition
   1827 +count, {!}, and a range specifier.  Once the {!} operator is entered in its
   1828 +entirety, a prompt will be given at the bottom of the screen for a UNIX
   1829 +command.  The text specified by the {!} operator is then deleted and
   1830 +passed/filtered/piped to the UNIX command you type.  The output of the UNIX
   1831 +command is then placed in your file.  For example, place the cursor at the
   1832 +beginning of the following line and {z^M}:
   1833 +
   1834 +ls -l vi.tutorial
   1835 +********* marks the bottom of the output from the ls command **********
   1836 +
   1837 +Now type {!!csh^M}.  The line will be replaced with the output from the ls
   1838 +command.  The {u} command works on {!}, also.
   1839 +
   1840 +Here is an extended exercise to display some of these capabilities.  When this
   1841 +tutorial was prepared, certain auxiliary programs were created to aid in its
   1842 +development.  Of major concern was the formatting of sections of the tutorial
   1843 +to fit on a single screen, particularly the first few sections.  What was
   1844 +needed was a vi command that would 'format' a paragraph; that is, fill out
   1845 +lines with as many words as would fit in eighty columns.  There is no such vi
   1846 +command.  Therefore, another method had to be found.
   1847 +
   1848 +Of course, nroff was designed to do text formatting.  However, it produces a
   1849 +'page'; meaning that there may be many blank lines at the end of a formatted
   1850 +paragraph from nroff.  The awk program was used to strip these blank lines from
   1851 +the output from nroff.  Below are the two files used for this purpose: I refer
   1852 +you to documentation on nroff and awk for a full explanation of their function.
   1853 +Position the cursor on the next line and {z^M}.
   1854 +
   1855 +******** contents of file f **********
   1856 +#
   1857 +nroff -i form.mac | awk "length != 0 { print }"
   1858 +***** contents of file form.mac ******
   1859 +.na
   1860 +.nh
   1861 +.ll 79
   1862 +.ec 
   1863 +.c2 
   1864 +.cc 
   1865 +**************************************
   1866 +
   1867 +Determine the line numbers of the two lines of file f.  They should be
   1868 +something like 574 and 575, although you better double check: this file is
   1869 +under constant revision and the line numbers may change inadvertently.  Then
   1870 +{:574,575w f^M}.  Do the same for the lines of file form.mac.  They will be
   1871 +approximately 577 and 582.  Then {:577,582w form.mac^M}.  File f must have
   1872 +execute privileges as a shell file: {:!chmod 744 f^M}.
   1873 +
   1874 +Observe that this paragraph is
   1875 +rather ratty in appearance.  With our newly created files we can
   1876 +clean it up dramatically.  Position the cursor at the beginning
   1877 +of this paragraph and type the following sequence of
   1878 +characters 
   1879 +(note that we must abandon temporarily our convention
   1880 +of curly braces since the command itself contains a curly brace - we 
   1881 +will use square brackets for the nonce): [!}f^M].
   1882 +
   1883 +Here is a brief explanation of what has happened.  By typing [!}f^M] we
   1884 +specified that the paragraph (all text between the cursor and the first blank
   1885 +line) will be removed from the edit file and piped to a UNIX program called
   1886 +"f".  This is a shell command file that we have created.  This shell file runs
   1887 +nroff, pipes its output to awk to remove blank lines, and the output from awk
   1888 +is then read back into our file in the place of the old, ratty paragraph.  The
   1889 +file form.mac is a list of commands to nroff to get it to produce paragraphs
   1890 +to our taste (the right margin is not justified, the line is 79 characters
   1891 +long, words are not hyphenated, and three nroff characters are renamed to
   1892 +avoid conflict: note that in this file, the {^G} you see there is vi's display
   1893 +of the control-G character, and not the two separate characters ^ up-arrow and
   1894 +G upper-case g).
   1895 +
   1896 +This example was created before the existence of the fmt program.  I now type
   1897 +[!}fmt^M] to get the same effect much faster.  Actually, I don't type those
   1898 +six keys each time: I have an abbreviation (which see).
   1899 +
   1900 +Section 35: searching with magic patterns
   1901 +
   1902 +The documentation available for "magic patterns" (i.e. regular expressions) is
   1903 +very scanty.  The following should explain this possibly very confusing feature
   1904 +of the editor.  This section assumes that the magic option is on.  To make
   1905 +sure, you might want to type {:set magic^M}.
   1906 +
   1907 +By "magic pattern" we mean a general description of a piece of text that the
   1908 +editor attempts to find during a search.  Most search patterns consist of
   1909 +strings of characters that must be matched exactly, e.g.  {/card/^M} searches
   1910 +for a specific string of four characters.  Let us suppose that you have
   1911 +discovered that you consistently have mistyped this simple word as either ccrd
   1912 +or czrd (this is not so far-fetched for touch typists).  You could {/ccrd/^M}
   1913 +and {n} until there are no more of this spelling, followed by {/czrd/^M} and
   1914 +{n} until there are no more of these.  Or you could {/c.rd/^M} and catch all of
   1915 +them on the first pass.  Try typing {/c.rd/^M} followed by several {n} and
   1916 +observe the effect.
   1917 +
   1918 +Line 27: card cord curd ceard
   1919 +
   1920 +When '.' is used in a search string, it has the effect of matching any single
   1921 +character.
   1922 +
   1923 +The character '^' (up-arrow) used at the beginning of a search string means
   1924 +the beginning of the line.  {/^Line 27/^M} will find the example line above,
   1925 +while {/Line 27/^M} will find an occurrence of this string anywhere in the
   1926 +line.
   1927 +
   1928 +Similarly, {/ the$/^M} will find all occurrences of the word 'the' occurring
   1929 +at the end of a line.  There are several of them in this file.
   1930 +
   1931 +Note that {:set nomagic^M} will turn off the special meaning of these magic
   1932 +characters EXCEPT for '^' and '$' which retain their special meanings at the
   1933 +beginning and end of a search string.  Within the search string they hold no
   1934 +special meaning.  Try {/\/ the$\//^M} and note that the dollar-sign is not the
   1935 +last character in the search string.  Let the dollar-sign be the last
   1936 +character in the search string, as in {/\/ the$/^M} and observe the result.
   1937 +
   1938 +Observe the result of {/back.*file/^M}.  This command, followed by sufficient
   1939 +{n}, will show you all lines in the file that contain both the words 'back'
   1940 +and 'file' on the same line.  The '*' magic character specifies that the
   1941 +previous regular expression (the '.' in our example) is to be repeatedly
   1942 +matched zero or more times.  In our example we specified that the words 'back'
   1943 +and 'file' must appear on the same line (they may be parts of words such as
   1944 +'backwards' or 'workfile') separated by any number (including zero) of
   1945 +characters.
   1946 +
   1947 +We could have specified that 'back' and 'file' are to be words by themselves by
   1948 +using the magic sequences '\<' or '\>'.  E.g.  {/\<back\>.*\<file\>/^M}.  The
   1949 +sequence '\<' specifies that this point of the search string must match the
   1950 +beginning of a word, while '\>' specifies a match at the end of a word.  By
   1951 +surrounding a string with these characters we have specified that they must be
   1952 +words.
   1953 +
   1954 +To find all words that begin with an 'l' or a 'w', followed by an 'a' or an
   1955 +'e', and ending in 'ing', try {/\<[lw][ea][a-z]*ing\>/^M}.  This will match
   1956 +words like 'learning', 'warning', and 'leading'.  The '[..]' notation matches
   1957 +exactly ONE character.  The character matched will be one of the characters
   1958 +enclosed in the square brackets.  The characters may be specified individually
   1959 +as in [abcd] or a '-' may be used to specify a range of characters as in [a-d].
   1960 +That is, [az] will match the letter 'a' OR the letter 'z', while [a-z] will
   1961 +match any of the lower case letters from 'a' through 'z'.  If you would like to
   1962 +match either an 'a', a '-', or a 'z', then the '-' must be escaped: [a\-z] will
   1963 +match ONE of the three characters 'a', '-', or 'z'.
   1964 +
   1965 +If you wish to find all Capitalized words, try {/\<[A-Z][a-z]*\>/^M}.  The
   1966 +following will find all character sequences that do NOT begin with an
   1967 +uncapitalized letter by applying a special meaning to the '^' character in
   1968 +square brackets: {/\<[^a-z][a-z]*\>/^M}.  When '^' is the first character of a
   1969 +square-bracket expression, it specifies "all but these characters".  (No
   1970 +one claimed vi was consistent.)
   1971 +
   1972 +To find all variable names (the first character is alphabetic, the remaining
   1973 +characters are alphanumeric):  try {/\<[A-Za-z][A-Za-z0-9]*\>/^M}.
   1974 +
   1975 +In summary, here are the primitives for building regular expressions:
   1976 +
   1977 +     ^      at beginning of pattern, matches beginning of line
   1978 +     $      at end of pattern, matches end of line
   1979 +     .      matches any single character
   1980 +     \<     matches the beginning of a word
   1981 +     \>     matches the end of a word
   1982 +     [str]  matches any single character in str
   1983 +     [^str] matches any single character NOT in str
   1984 +     [x-y]  matches any character in the ASCII range between x and y
   1985 +     *      matches any number (including zero) of the preceding pattern
   1986 +
   1987 +Section 36: advanced substitution: {:s} 
   1988 +
   1989 +The straightforward colon-substitute command looks like the substitute
   1990 +command of most line-oriented editors.  Indeed, vi is nothing more than a
   1991 +superstructure on the line-oriented editor ex and the colon commands are
   1992 +simply a way of accessing commands within ex (see section #EX).  This gives us
   1993 +a lot of global file processing not usually found in visual oriented editors.
   1994 +
   1995 +The colon-substitute command looks like: {:s/ .. / .. /^M} and will find the
   1996 +pattern specified after the first slash (this is called the search pattern),
   1997 +and replace it with the pattern specified after the second slash (called,
   1998 +obviously enough, the replacement pattern).  E.g. position the cursor on line
   1999 +28 below and {:s/esample/example/^M}:
   2000 +
   2001 +Line 28: This is an esample.
   2002 +
   2003 +The {u} and {U} commands work for {:s}.  The first pattern (the search pattern)
   2004 +may be a regular expression just as for the search command (after all, it IS a
   2005 +search, albeit limited to the current line).  Do an {u} on the above line, and
   2006 +try the following substitute, which will do almost the same thing: 
   2007 +{:s/s[^ ]/x/^M}.  
   2008 +Better undo it with {u}.  The first pattern {s[^ ]} matches an 's'
   2009 +NOT followed by a blank: the search therefore ignores the 's'es in 'This' and
   2010 +'is'.  However, the character matched by {[^ ]} must appear in the replacement
   2011 +pattern.  But, in general, we do not know what that character is!  (In this
   2012 +particular example we obviously do, but more complicated examples will follow.)
   2013 +Therefore, vi (really ex) has a duplication mechanism to copy patterns matched
   2014 +in the search string into the replacement string.  Line 29 below is a copy of
   2015 +line 28 above so you can adjust your screen.
   2016 +
   2017 +Line 29: This is an esample.
   2018 +
   2019 +In general, you can nest parts of the search pattern in \( .. \) and refer to
   2020 +it in the replacement pattern as \n, where n is a digit.  The problem outlined
   2021 +in the previous paragraph is solved with {:s/s\([^ ]\)/x\1/^M}: try it.  Here
   2022 +\1 refers to the first pattern grouping \( .. \) in the search string.
   2023 +
   2024 +Obviously, for a single line, this is rather tedious.  Where it becomes
   2025 +powerful, if not necessary, is in colon-substitutes that cover a range of
   2026 +lines.  (See the next section for a particularly comprehensive example.)
   2027 +
   2028 +If the entire character sequence matched by the search pattern is needed in
   2029 +the replacement pattern, then the unescaped character '&' can be used.  On
   2030 +Line 29 above, try {:s/an e.ample/not &/^M}.  If another line is to have the
   2031 +word 'not' prepended to a pattern, then '~' can save you from re-typing the
   2032 +replacement pattern.  E.g. {:s/some pattern/~/^M} after the previous example
   2033 +would be equivalent to {:s/some pattern/not &/^M}.
   2034 +
   2035 +One other useful replacement pattern allows you to change the case of
   2036 +individual letters.  The sequences {\u} and {\l} cause the immediately
   2037 +following character in the replacement to be converted to upper- or lower-case,
   2038 +respectively, if this character is a letter.  The sequences {\U} and {\L} turn
   2039 +such conversion on, either until {\E} or {\e} is encountered, or until the end
   2040 +of the replacement pattern.
   2041 +
   2042 +For example, position the cursor on a line: pick a line, any line.  Type
   2043 +{:s/.*/\U&/^M} and observe the result.  You can undo it with {u}.
   2044 +
   2045 +The search pattern may actually match more than once on a single line.
   2046 +However, only the first pattern is substituted.  If you would like ALL
   2047 +patterns matched on the line to be substituted, append a 'g' after the
   2048 +replacement pattern: {:s/123/456/g^M} will substitute EVERY occurrence
   2049 +on the line of 123 with 456.
   2050 +
   2051 +Section 37: advanced line addressing: {:p} {:g} {:v}
   2052 +
   2053 +Ex (available through the colon command in vi) offers several methods for
   2054 +specifying the lines on which a set of commands will act.  For example, if you
   2055 +would like to see lines 50 through 100 of your file: {:50,100p^M} will display
   2056 +them, wait for you to [Hit return to continue], and leave you on line 100.
   2057 +Obviously, it would be easier just to do {100G} from within vi.  But
   2058 +what if you would like to make changes to just those lines?  Then the
   2059 +addressing is important and powerful.
   2060 +
   2061 +Line 30: This is a text.
   2062 +Line 31: Here is another text.
   2063 +Line 32: One more text line.
   2064 +
   2065 +The lines above contain a typing error that the author of this tutorial tends
   2066 +to make every time he attempts to type the word 'test'.  To change all of these
   2067 +'text's into 'test's, try the following:
   2068 +{:/^Line 30/,/^Line 32/s/text/test/^M}.  This finds the beginning and end of
   2069 +the portion of text to be changed, and limits the substitution to each of the
   2070 +lines in that range.  The {u} command applies to ALL of the substitutions as 
   2071 +a group.
   2072 +
   2073 +This provides a mechanism for powerful text manipulations.
   2074 +And very complicated examples.
   2075 +
   2076 +Line 33: This test is a.
   2077 +Line 34: Here test is another.
   2078 +Line 35: One line more test.
   2079 +
   2080 +The above three lines have the second word out of order.  The following command
   2081 +string will put things right.  Be very careful when typing this: it is very
   2082 +long, full of special characters, and easy to mess up.  You may want to
   2083 +consider reading the following section to understand it before trying the
   2084 +experiment.  Don't worry about messing up the rest of the file, though: the
   2085 +address range is specified.
   2086 +
   2087 +{:/^Line 33/,/^Line 35/s/\([^:]*\): \([^ ]*\) \([^ ]*\) \([^.]*\)/\1: \2 \4 \3/^M}
   2088 +
   2089 +There are several things to note about this command string.  First of all, the
   2090 +range of the substitute was limited by the address specification {/^Line
   2091 +33/,/^Line 35/^M}.  It might have been simpler to do {:set number^M} to see the
   2092 +line numbers directly, and then, in place of the two searches, typed
   2093 +the line numbers, e.g. {1396,1398}.  Or to mark the lines with {ma} and {mb}
   2094 +and use {'a,'b}.
   2095 +
   2096 +Then follows the substitute pattern itself.  To make it easier to understand
   2097 +what the substitute is doing, the command is duplicated below with the various
   2098 +patterns named for easier reference:
   2099 +
   2100 +     s/\([^:]*\): \([^ ]*\) \([^ ]*\) \([^.]*\)/\1: \2 \4 \3/
   2101 +       |--\1---|  |--\2---| |--\3---| |--\4---|
   2102 +      |--------search pattern------------------|-replacement|
   2103 +                                               |--pattern---|
   2104 +
   2105 +In overview, the substitute looks for a particular pattern made up of 
   2106 +sub-patterns, which are named \1, \2, \3, and \4.  These patterns are specified
   2107 +by stating what they are NOT.  Pattern \1 is the sequence of characters that
   2108 +are NOT colons: in the search string, {[^:]} will match exactly one character
   2109 +that is not a colon, while appending the asterisk {[^:]*} specifies that the
   2110 +'not a colon' pattern is to be repeated until no longer satisfied, and
   2111 +{\([^:]*\)} then gives the pattern its name, in this case \1.  Outside of the
   2112 +specification of \1 comes {: }, specifying that the next two characters must be
   2113 +a colon followed by a blank.
   2114 +
   2115 +Patterns \2 and \3 are similar, specifying character sequences that are
   2116 +not blanks.  Pattern \4 matches up to the period at the end of the line.
   2117 +
   2118 +The replacement pattern then consists of specifying the new order of the
   2119 +patterns.
   2120 +
   2121 +This is a particularly complicated example, perhaps the most complicated
   2122 +in this tutorial/reference.  For our small examples, it is obviously
   2123 +tedious and error prone.  For large files, however, it may be the most
   2124 +efficient way to make the desired modifications.
   2125 +
   2126 +(The reader is advised to look at the documentation for awk.  This tool is very
   2127 +powerful and slightly simpler to use than vi for this kind of file
   2128 +manipulation.  But, it is another command language to learn.)
   2129 +
   2130 +Many times, you will not want to operate on every line in a certain
   2131 +range.  Rather you will want to make changes on lines that satisfy
   2132 +certain patterns; e.g. for every line that has the string 'NPS' on it,
   2133 +change 'NPS' to 'Naval Postgraduate School'.  The {:g} addressing
   2134 +command was designed for this purpose.  The example of this paragraph
   2135 +could be typed as {:g/NPS/s//Naval Postgraduate School/^M}.
   2136 +
   2137 +The general format of the command is {:g/(pattern)/cmds^M} and it
   2138 +works in the following way: all lines that match the pattern
   2139 +following the {:g} are 'tagged' in a special way.  Then each of these
   2140 +lines have the commands following the pattern executed over them.
   2141 +
   2142 +Line 36: ABC rhino george farmer Dick jester lest
   2143 +Line 37: george farmer rhino lest jester ABC
   2144 +Line 38: rhino lest george Dick farmer ABC jester 
   2145 +
   2146 +Type:
   2147 +
   2148 +{:g/^Line.*ABC/s/Dick/Harry Binswanger/|s/george farmer/gentleman george/p^M}
   2149 +
   2150 +There are several things of note here.  First, lines 36, 37, and 38 above are
   2151 +tagged by the {:g}.  Type {:g/^Line.*ABC/p^M} to verify this.  Second, there
   2152 +are two substitutes on the same line separated by '|'.  In general, any colon
   2153 +commands can be strung together with '|'.  Third, both substitutes operate on
   2154 +all three lines, even though the first stubstitute works on only two of the
   2155 +lines (36 and 38).  Fourth, the second substitute works on only two lines (36
   2156 +and 37) and those are the two lines printed by the trailing 'p'.
   2157 +
   2158 +The {:v} command works similarly to the {:g} command, except that the sense of
   2159 +the test for 'tagging' the lines is reversed: all lines NOT matching the search
   2160 +pattern are tagged and operated on by the commands.
   2161 +
   2162 +Using {^V} to quote carriage return (see section 39) can be used in global
   2163 +substitutions to split two lines.  For example, the command 
   2164 +{:g/\.  /s//.^V^M/g^M} will change your file so that each sentence is on a 
   2165 +separate line.  (Note that we have to 'escape' the '.', because '.' by itself
   2166 +matches any character.  Our command says to find any line which contains a 
   2167 +period followed by 2 spaces, and inserts a carriage return after the period.)
   2168 +
   2169 +Caveat:  In some of the documentation for ex and vi you may find the
   2170 +comment to the effect that {\^M} can be used between commands following
   2171 +{:g}.  The author of this tutorial has never gotten this to work and has
   2172 +crashed the editor trying.
   2173 +
   2174 +Section 38: higher level text objects and nroff: {(} {)} [{] [}] {[[} {]]}
   2175 +
   2176 +(Note: this section may be a little confusing because of our command
   2177 +notation.  Using curly braces to surround command strings works fine as
   2178 +long as the command string does not contain any curly braces itself.
   2179 +However, the curly braces are legitimate commands in vi.  Therefore, for
   2180 +any command sequence that contains curly braces, we will surround that
   2181 +sequence with SQUARE braces, as on the previous Section line.)
   2182 +
   2183 +In working with a document, particularly if using the text formatting
   2184 +programs nroff or troff, it is often advantageous to work in terms of
   2185 +sentences, paragraphs, and sections.  The operations {(} and {)} move to
   2186 +the beginning of the previous and next sentences, respectively.  Thus
   2187 +the command {d)} will delete the rest of the current sentence; likewise
   2188 +{d(} will delete the previous sentence if you are at the beginning of
   2189 +the current sentence, or, if you are not at the beginning of a sentence,
   2190 +it will delete the current sentence from the beginning 
   2191 +up to where you are.
   2192 +
   2193 +A sentence is defined to end at a '.', '!', or '?' which is followed
   2194 +by either the end of a line, or by two spaces.  Any number of closing
   2195 +')', ']', '"', and ''' characters may appear after the '.', '!', or '?'
   2196 +before the spaces or end of line.  Therefore, the {(} and {)} commands
   2197 +would recognize only one sentence in the following line, but two
   2198 +sentences on the second following line.
   2199 +
   2200 +Line 39: This is one sentence. Even though it looks like two.
   2201 +Line 40: This is two sentences.  Because it has two spaces after the '.'.
   2202 +
   2203 +The operations [{] and [}] move over paragraphs and the operations {[[}
   2204 +and {]]} move over sections.
   2205 +
   2206 +A paragraph begins after each empty line, and also at each of a set of nroff
   2207 +paragraph macros.  A section begins after each line with a form-feed ^L in the
   2208 +first column, and at each of a set of nroff section macros.  When preparing a
   2209 +text file as input to nroff, you will probably be using a set of nroff macros
   2210 +to make the formatting specifications easier, or more to your taste.  These
   2211 +macros are invoked by beginning a line with a period followed by the one or two
   2212 +letter macro name. Vi has been programmed to recognize these nroff macros, and
   2213 +if it doesn't recognize your particular macro you can use the {:set paragraphs}
   2214 +or {:set sections} commands so that it will.
   2215 +
   2216 +Section 39: more about inserting text
   2217 +
   2218 +There are a number of characters which you can use to make correnctions
   2219 +during input mode.  These are summarized in the following table.
   2220 +
   2221 +    ^H      deletes the last input character
   2222 +    ^W      deletes the last input word
   2223 +    (erase) same as ^H; each terminal can define its own erase character; 
   2224 +            for some it is ^H, for others it is the DELETE key, and for
   2225 +            others it is '@'.
   2226 +    (kill)  deletes the input on this line; each terminal can define its
   2227 +            own line-kill character; for some it is ^U, for others it is
   2228 +            '@'; you will need to experiment on your terminal to find
   2229 +            out what your line-kill and erase characters are.
   2230 +    \       escapes a following ^H, (kill), and (erase) characters: i.e.
   2231 +            this is how to put these characters in your file.
   2232 +    ^[      escape key; ends insertion mode
   2233 +    ^?      the delete key; interrupts an insertion, terminating it
   2234 +            abnormally.
   2235 +    ^M      the return key; starts a new line.
   2236 +    ^D      backtabs over the indentation set by the autoindent option
   2237 +    0^D     backtabs over all indentation back to the beginning of the line
   2238 +    ^^D     (up-arrow followed by control-d)same as 0^D, except the indentation 
   2239 +	    will be restored at the beginning of the next line.
   2240 +    ^V      quotes the next non-printing character into the file
   2241 +
   2242 +If you wish to type in your erase or kill character (say # or @ or ^U) then you
   2243 +must precede it with a \, just as you would do at the normal system command
   2244 +level.  A more general way of typing non-printing characters into the file is
   2245 +to precede them with a ^V.  The ^V echoes as a ^ character on which the cursor
   2246 +rests.  This indicates that the editor expects you to type a control character
   2247 +and it will be inserted into the file at that point.  There are a few
   2248 +exceptions to note.  The implementation of the editor does not allow the null
   2249 +character ^@ to appear in files.  Also the linefeed character ^J is used by the
   2250 +editor to separate lines in the file, so it cannot appear in the middle of a
   2251 +line.  (Trying to insert a ^M into a file, or putting it in the replacement 
   2252 +part of a substitution string will result in the matched line being split in 
   2253 +two.  This, in effect, is how to split lines by using a substitution.)  You can 
   2254 +insert any other character, however, if you wait for the editor to echo the ^ 
   2255 +before you type the character.  In fact, the editor will treat a following 
   2256 +letter as a request for the corresponding control character.  This is the only 
   2257 +way to type ^S or ^Q, since the system normally uses them to suspend and resume 
   2258 +output and never gives them to the editor to process.
   2259 +
   2260 +If you are using the autoindent option you can backtab over the indent which it
   2261 +supplies by typing a ^D.  This backs up to the boundary specified by the
   2262 +shiftwidth option.  This only works immediately after the supplied autoindent.
   2263 +
   2264 +When you are using the autoindent option you may wish to place a label at the
   2265 +left margin of a line.  The way to do this easily is to type ^ (up-arrow) and
   2266 +then ^D.  The editor will move the cursor to the left margin for one line, and
   2267 +restore the previous indent on the next.  You can also type a 0 followed
   2268 +immediately by a ^D if you wish to kill all indentation and not have it resume
   2269 +on the next line.
   2270 +
   2271 +Section 40: more on operators: {d} {c} {<} {>} {!} {=} {y}
   2272 +
   2273 +Below is a non-exhaustive list of commands that can follow the operators
   2274 +to affect the range over which the operators will work.  However, note
   2275 +that the operators {<}, {>}, {!}, and {=} do not operate on any object
   2276 +less than a line.  Try {!w} and you will get a beep.  To get the
   2277 +operator to work on just the current line, double it.  E.g. {<<}.
   2278 +
   2279 +    suffix        will operate on
   2280 +    ------        ------------------------
   2281 +      ^[            cancels the command
   2282 +      w             the word to the right of the cursor
   2283 +      W             ditto, but ignoring punctuation
   2284 +      b             the word to the left of the cursor
   2285 +      B             ditto, but ignoring punctuation
   2286 +      e             see below.
   2287 +      E               ditto
   2288 +      (space)       a character
   2289 +      $             to the end of the line
   2290 +      ^             to the beginning of the line
   2291 +      / .. /        up to, but not including, the string
   2292 +      ? .. ?        back to and including the string
   2293 +      fc            up to and including the occurrence of c 
   2294 +      Fc            back to and including the occurrence of c
   2295 +      tc            up to but not including the occurrence of c
   2296 +      Tc            back to but not including the occurrence of c
   2297 +      ^M            TWO lines (that's right: two)
   2298 +      (number)^M    that many lines plus one
   2299 +      (number)G     up to and including line (number)
   2300 +      (             the previous sentence if you are at the beginning of
   2301 +                    the current sentence, or the current sentence up to where 
   2302 +                    you are if you are not at the beginning of the current 
   2303 +                    sentence.  Here, 'sentence' refers to the intuitive
   2304 +                    notion of an English sentence, ending with '!', '?',
   2305 +                    or '.' and followed by an end of line or two spaces.
   2306 +      )             the rest of the current sentence
   2307 +      {             analogous to '(', but in reference to paragraphs:
   2308 +                    sections of text surrounded by blank lines
   2309 +      }             analogous to ')', but in reference to paragraphs
   2310 +      [[            analogous to '(', but in reference to sections
   2311 +      ]]            analogous to ')', but in reference to sections
   2312 +      H             the first line on the screen
   2313 +      M             the middle line on the screen
   2314 +      L             the last line on the screen
   2315 +      3L            through the third line from the bottom of the screen
   2316 +      ^F            forward a screenful
   2317 +      ^B            backward a screenful
   2318 +      :
   2319 +      :  etc. etc. etc.
   2320 +
   2321 +This list is not exhaustive, but it should be sufficient to get the idea
   2322 +across: after the operator, you can specify a range with a move-the-cursor
   2323 +command, and that is the region of text over which the operator will be
   2324 +effective.
   2325 +
   2326 +Section 41: abbreviations: {:ab}
   2327 +
   2328 +When typing large documents you may find yourself typing a large phrase
   2329 +over and over.  Vi gives you the ability to specify an abbreviation for
   2330 +a long string such that typing the abbreviation will automatically
   2331 +expand into the longer phrase.
   2332 +
   2333 +Type {:ab nps Naval Postgraduate School^M}.  Now type:
   2334 +
   2335 +{iThis is to show off the nps's UNIX editor.^M^[}
   2336 +
   2337 +Section 42: vi's relationship with the ex editor: {:}
   2338 +
   2339 +Vi is actually one mode of editing within the editor ex.  When you are
   2340 +running vi you can escape to the line oriented editor of ex by giving
   2341 +the command {Q}.  All of the colon-commands which were introduced above
   2342 +are available in ex.  Likewise, most ex commands can be invoked from vi
   2343 +using {:}.   
   2344 +
   2345 +In rare instances, an internal error may occur in vi.  In this case you
   2346 +will get a diagnostic and will be left in the command mode of ex.  You can
   2347 +then save your work and quit if you wish by giving the command {x} after
   2348 +the colon prompt of ex.  Or you can reenter vi (if you are brave) by
   2349 +giving ex the command {vi}.
   2350 +
   2351 +Section 43: vi on hardcopy terminals and dumb terminals: open mode
   2352 +
   2353 +(The author has not checked the following documentation for accuracy.  It is
   2354 +abstracted from the Introduction to Vi Editing document.)
   2355 +
   2356 +If you are on a hardcopy terminal or a terminal which does not have a cursor
   2357 +which can move off the bottom line, you can still use the command set of vi,
   2358 +but in a different mode.  When you give the vi command to UNIX, the editor will
   2359 +tell you that it is using open mode.  This name comes from the open command in
   2360 +ex, which is used to get into the same mode.
   2361 +
   2362 +The only difference between visual mode (normal vi) and open mode is the way in
   2363 +which the text is displayed.
   2364 +
   2365 +In open mode the editor uses a single line window into the file, and moving
   2366 +backward and forward in the file causes new lines to be displayed, always below
   2367 +the current line.  Two commands of vi work differently in open: {z} and {^R}.
   2368 +The {z} command does not take parameters, but rather draws a window of context
   2369 +around the current line and then returns you to the current line.
   2370 +
   2371 +If you are on a hardcopy terminal, the {^R} command will retype the current
   2372 +line.  On such terminals, the editor normally uses two lines to represent the
   2373 +current line.  The first line is a copy of the line as you started to edit it,
   2374 +and you work on the line below this line.  When you delete characters, the
   2375 +editor types a number of \'s to show you the characters which are deleted.  The
   2376 +editor also reprints the current line soon after such changes so that you can
   2377 +see what the line looks like again.
   2378 +
   2379 +It is sometimes useful to use this mode on very slow terminals which can
   2380 +support vi in the full screen mode.  You can do this by entering ex and using
   2381 +an {open} command.
   2382 +
   2383 +*********************************************************************
   2384 +Section 44: options: {:set} {setenv EXINIT}
   2385 +
   2386 +You will discover options as you need them.  Do not worry about them very much
   2387 +on the first pass through this document.  My advice is to glance through them,
   2388 +noting the ones that look interesting, ignoring the ones you don't understand,
   2389 +and try re-scanning them in a couple of weeks.
   2390 +
   2391 +If you decide that you have a favorite set of options and would like to change
   2392 +the default values for the editor, place a {setenv EXINIT} command in your
   2393 +.login file.  When you are given an account under UNIX your directory has
   2394 +placed in it a file that is executed each time you log in.  If one of the
   2395 +commands in this file sets the environment variable EXINIT to a string of vi
   2396 +commands, you can have many things done for you each time you invoke vi.  For
   2397 +example, if you decide that you don't like tabstops placed every eight columns
   2398 +but prefer every four columns, and that you wish the editor to insert linefeeds
   2399 +for you when your typing gets you close to column 72, and you want
   2400 +autoindentation, then include the following line in your .login file:
   2401 +
   2402 +setenv EXINIT='set tabstop=4 wrapmargin=8 autoindent'
   2403 +
   2404 +or equivalently
   2405 +
   2406 +setenv EXINIT='se ts=4 wm=8 ai'
   2407 +
   2408 +Each time you bring up vi, this command will be executed and the options set.
   2409 +
   2410 +There are forty options in the vi/ex editor that the user can set for his/her
   2411 +own convenience.  They are described in more detail in individual sections
   2412 +below.  The section line will show the full spelling of the option name, the
   2413 +abbreviation, and the default value of the option.  The text itself
   2414 +comes from the ex reference manual and is not the epitome of clarity.
   2415 +
   2416 +Section 44.1: {autoindent}, {ai} default: noai
   2417 +
   2418 +Can be used to ease the preparation of structured program text.  At the
   2419 +beginning of each append, change or insert command or when a new line is opened
   2420 +or created by an append, change, insert, or substitute operation within open or
   2421 +visual mode, ex looks at the line being appended after, the first line changed
   2422 +or the line inserted before and calculates the amount of white space at the
   2423 +start of the line.  It then aligns the cursor at the level of indentation so
   2424 +determined.
   2425 +
   2426 +If the user then types lines of text in, they will continue to be justified at
   2427 +the displayed indenting level.  If more white space is typed at the beginning
   2428 +of a line, the following line will start aligned with the first non-white
   2429 +character of the previous line.  To back the cursor up to the preceding tab
   2430 +stop one can hit {^D}.  The tab stops going backwards are defined at multiples
   2431 +of the shiftwidth option.  You cannot backspace over the indent, except by
   2432 +sending an end-of-file with a {^D}.  A line with no characters added to it
   2433 +turns into a completely blank line (the white space provided for the autoindent
   2434 +is discarded). Also specially processed in this mode are lines beginning with
   2435 +an up-arrow `^' and immediately followed by a {^D}.  This causes the input to
   2436 +be repositioned at the beginning of the line, but retaining the previous indent
   2437 +for the next line.  Similarly, a `0' followed by a {^D} repositions at the
   2438 +beginning but without retaining the previous indent.  Autoindent doesn't happen
   2439 +in global commands or when the input is not a terminal.
   2440 +
   2441 +Section 44.2: {autoprint}, {ap} default: ap
   2442 +
   2443 +Causes the current line to be printed after each delete, copy, join, move,
   2444 +substitute, t, undo or shift command.  This has the same effect as supplying a
   2445 +trailing `p' to each such command.  Autoprint is suppressed in globals, and
   2446 +only applies to the last of many commands on a line.
   2447 +
   2448 +Section 44.3: {autowrite}, {aw} default: noaw
   2449 +
   2450 +Causes the contents of the buffer to be written to the current file if you have
   2451 +modified it and give a next, rewind, stop, tag, or {!} command, or a control-
   2452 +up-arrow {^^} (switch files) or {^]} (tag goto) command in visual.  Note, that
   2453 +the edit and ex commands do not autowrite.  In each case, there is an
   2454 +equivalent way of switching when autowrite is set to avoid the autowrite
   2455 +({edit} for next, rewind!  for rewind, stop!  for stop, tag!  for tag, shell
   2456 +for {!}, and {:e #} and a {:ta!} command from within visual).
   2457 +
   2458 +Section 44.4: {beautify}, {bf} default: nobeautify
   2459 +
   2460 +Causes all control characters except tab ^I, newline ^M and form-feed ^L to be
   2461 +discarded from the input.  A complaint is registered the first time a backspace
   2462 +character is discarded.  Beautify does not apply to command input.
   2463 +
   2464 +Section 44.5: {directory}, {dir} default: dir=/tmp 
   2465 +
   2466 +Specifies the directory in which ex places its buffer file.  If this directory
   2467 +in not writable, then the editor will exit abruptly when it fails to be able to
   2468 +create its buffer there.
   2469 +
   2470 +Section 44.6: {edcompatible} default: noedcompatible
   2471 +
   2472 +Causes the presence or absence of g and c suffixes on substitute commands to be
   2473 +remembered, and to be toggled by repeating the suffices.  The suffix r makes
   2474 +the substitution be as in the {~} command, instead of like {&}.
   2475 +
   2476 +[Author's note: this should not concern users of vi.]
   2477 +
   2478 +Section 44.7: {errorbells}, {eb} default: noeb
   2479 +
   2480 +Error messages are preceded by a bell.  However, bell ringing in open and
   2481 +visual modes on errors is not suppressed by setting noeb.  If possible the
   2482 +editor always places the error message in a standout mode of the terminal (such
   2483 +as inverse video) instead of ringing the bell.
   2484 +
   2485 +Section 44.8: {hardtabs}, {ht} default: ht=8
   2486 +
   2487 +Gives the boundaries on which terminal hardware tabs are set (or on which the
   2488 +system expands tabs).
   2489 +
   2490 +Section 44.9: {ignorecase}, {ic} default: noic
   2491 +
   2492 +All upper case characters in the text are mapped to lower case in regular
   2493 +expression matching.  In addition, all upper case characters in regular
   2494 +expressions are mapped to lower case except in character class specifications
   2495 +(that is, character in square brackets).
   2496 +
   2497 +Section 44.10: {lisp} default: nolisp
   2498 +
   2499 +Autoindent indents appropriately for lisp code, and the {(}, {)}, [{], [}],
   2500 +{[[}, and {]]} commands in open and visual modes are modified in a
   2501 +striaghtforward, intuitive fashion to have meaning for lisp.
   2502 +
   2503 +[Author's note: but don't ask me to define them precisely.]
   2504 +
   2505 +Section 44.11: {list} default: nolist
   2506 +
   2507 +All printed lines will be displayed (more) unambiguously, showing tabs as ^I
   2508 +and end-of-lines with `$'.  This is the same as in the ex command {list}.
   2509 +
   2510 +Section 44.12: {magic} default: magic for {ex} and {vi}, nomagic for edit.
   2511 +
   2512 +If nomagic is set, the number of regular expression metacharacters is greatly
   2513 +reduced, with only up-arrow `^' and `$' having special effects.  In addition
   2514 +the metacharacters `~' and `&' of the replacement pattern are treated as normal
   2515 +characters.  All the normal metacharacters may be made magic when nomagic is
   2516 +set by preceding them with a `\'.
   2517 +
   2518 +[Author's note: In other words, if magic is set a back-slant turns the magic
   2519 +off for the following character, and if nomagic is set a back-slant turns the
   2520 +magic ON for the following character.  And, no, we are not playing Dungeons and
   2521 +Dragons, although I think the writers of these option notes must have played it
   2522 +all the time.]
   2523 +
   2524 +Section 44.13: {mesg} default: mesg
   2525 +
   2526 +Causes write permission to be turned off to the terminal while you are in
   2527 +visual mode, if nomesg is set.
   2528 +
   2529 +[Author's note: I don't know if anyone could have made any one sentence
   2530 +paragraph more confusing than this one.  What it says is: mesg allows people to
   2531 +write to you even if you are in visual or open mode; nomesg locks your terminal
   2532 +so they can't write to you and mess up your screen.]
   2533 +
   2534 +Section 44.14: {number, nu} default: nonumber
   2535 +
   2536 +Causes all output lines to be printed with their line numbers.  In addition
   2537 +each input line will be prompted with its line number.
   2538 +
   2539 +Section 44.15: {open} default: open
   2540 +
   2541 +If {noopen}, the commands open and visual are not permitted.  This is set for
   2542 +edit to prevent confusion resulting from accidental entry to open or visual
   2543 +mode.
   2544 +
   2545 +[Author's note: As you may have guessed by now, there are actually three
   2546 +editors available under Berkeley UNIX that are in reality the same
   2547 +program, ex, with different options set: ex itself, vi, and edit.]
   2548 +
   2549 +Section 44.16: {optimize, opt} default: optimize
   2550 +
   2551 +Throughput of text is expedited by setting the terminal to not do automatic
   2552 +carriage returns when printing more than one (logical) line of output, greatly
   2553 +speeding output on terminals without addressable cursors when text with leading
   2554 +white space is printed.
   2555 +
   2556 +[Author's note: I still don't know what this option does.]
   2557 +
   2558 +Section 44.17: {paragraphs, para} default: para=IPLPPPQPP LIbp
   2559 +
   2560 +Specifies the paragraphs for the [{] and [}] operations in open and visual.
   2561 +The pairs of characters in the option's value are the names of the nroff macros
   2562 +which start paragraphs.
   2563 +
   2564 +Section 44.18: {prompt} default: prompt
   2565 +
   2566 +Command mode input is prompted for with a `:'.
   2567 +
   2568 +[Author's note: Doesn't seem to have any effect on vi.]
   2569 +
   2570 +Section 44.19: {readonly}, {ro} default: noro, unless invoked with -R 
   2571 +                                         or insufficient privileges on file
   2572 +
   2573 +This option allows you to guarantee that you won't clobber your file by
   2574 +accident.  You can set the option and writes will fail unless you use an `!'
   2575 +after the write.  Commands such as {x}, {ZZ}, the autowrite option, and in
   2576 +general anything that writes is affected.  This option is turned on if you
   2577 +invoke the editor with the -R flag.
   2578 +
   2579 +Section 44.20: {redraw} default: noredraw
   2580 +
   2581 +The editor simulates (using great amounts of output), an intelligent terminal
   2582 +on a dumb terminal (e.g. during insertions in visual the characters to the
   2583 +right of the cursor position are refreshed as each input character is typed).
   2584 +Useful only at very high baud rates, and should be used only if the system is
   2585 +not heavily loaded: you will notice the performance degradation yourself.
   2586 +
   2587 +Section 44.21: {remap} default: remap
   2588 +
   2589 +If on, macros are repeatedly tried until they are unchanged.  For example, if o
   2590 +is mapped to O, and O is mapped to I, then if remap is set, o will map to I,
   2591 +but if noremap is set, it will map to O .
   2592 +
   2593 +Section 44.22: {report} default: report=5 for ex and vi, 2 for edit
   2594 +
   2595 +Specifies a threshold for feedback from commands.  Any command which modifies
   2596 +more than the specified number of lines will provide feedback as to the scope
   2597 +of its changes.  For commands such as global, open, undo, and visual which have
   2598 +potentially more far reaching scope, the net change in the number of lines in
   2599 +the buffer is presented at the end of the command, subject to this same
   2600 +threshold.  Thus notification is suppressed during a global command on the
   2601 +individual commands performed.
   2602 +
   2603 +Section 44.23: {scroll} default: scroll=1/2 window
   2604 +
   2605 +Determines the number of logical lines scrolled when a {^D} is received from a
   2606 +terminal in command mode, and determines the number of lines printed by a
   2607 +command mode z command (double the value of scroll).
   2608 +
   2609 +[Author's note: Doesn't seem to affect {^D} and {z} in visual (vi) mode.]
   2610 +
   2611 +Section 44.24: sections {sections} default: sections=SHNHH HU 
   2612 +
   2613 +Specifies the section macros from nroff for the {[[} and {]]} operations in
   2614 +open and visual.  The pairs of characters in the options's value are the names
   2615 +of the macros which start paragraphs.
   2616 +
   2617 +Section 44.25: {shell}, {sh} default: sh=/bin/sh 
   2618 +
   2619 +Gives the path name of the shell forked for the shell escape command `!', and
   2620 +by the shell command.  The default is taken from SHELL in the environment, if
   2621 +present.
   2622 +
   2623 +[Editor's note: I would suggest that you place the following line in
   2624 +your .login file:
   2625 +setenv SHELL '/bin/csh'
   2626 +]
   2627 +
   2628 +Section 44.26: {shiftwidth}, {sw} default: sw=8 
   2629 +
   2630 +Used in reverse tabbing with {^D} when using autoindent to append text, and
   2631 +used by the shift commands.  Should probably be the same value as the tabstop
   2632 +option.
   2633 +
   2634 +Section 44.27: {showmatch}, {sm} default: nosm 
   2635 +
   2636 +In open and visual mode, when a `)' or `}' is typed, if the matching `(' or `{'
   2637 +is on the screen, move the cursor to it for one second.  Extremely useful with
   2638 +complicated nested expressions, or with lisp.
   2639 +
   2640 +Section 44.28: {slowopen}, {slow} default: terminal dependent
   2641 +
   2642 +Affects the display algorithm used in visual mode, holding off display updating
   2643 +during input of new text to improve throughput when the terminal in use is both
   2644 +slow and unintelligent.  See "An Introduction to Display Editing with Vi" for
   2645 +more details.
   2646 +
   2647 +Section 44.29: {tabstop}, {ts} default: ts=8
   2648 +
   2649 +The editor expands tabs ^I to tabstop boundaries in the display.
   2650 +
   2651 +Section 44.30: {taglength}, {tl} default: tl=0
   2652 +
   2653 +Tags are not significant beyond this many characters.
   2654 +A value of zero (the default) means that all characters are significant.
   2655 +
   2656 +Section 44.31: {tags} default: tags=tags /usr/lib/tags
   2657 +
   2658 +A path of files to be used as tag files for the tag command.  A requested tag
   2659 +is searched for in the specified files, sequentially.  By default files called
   2660 +tags are searched for in the current directory and in /usr/lib (a master file
   2661 +for the entire system).
   2662 +
   2663 +[Author's note: The author of this tutorial has never used this option, nor
   2664 +seen it used.  I'm not even sure I know what they are talking about.]
   2665 +
   2666 +Section 44.32: {term} default: from environment variable TERM
   2667 +
   2668 +The terminal type of the output device.
   2669 +
   2670 +Section 44.33: {terse} default: noterse
   2671 +
   2672 +Shorter error diagnostics are produced for the experienced user.
   2673 +
   2674 +Section 44.34: {timeout} default: timeout
   2675 +
   2676 +Causes macros to time out after one second.  Turn it off and they will
   2677 +wait forever.  This is useful if you want multi-character macros, but if
   2678 +your terminal sends escape sequences for arrow keys, it will be
   2679 +necessary to hit escape twice to get a beep.
   2680 +
   2681 +[Editor's note: Another paragraph which requires a cryptographer.]
   2682 +
   2683 +Section 44.35: ttytype
   2684 +
   2685 +[Editor's note: I have found no documentation for this option at all.]
   2686 +
   2687 +Section 44.36: {warn} default: warn
   2688 +
   2689 +Warn if there has been `[No write since last change]' before a `!' command
   2690 +escape.
   2691 +
   2692 +Section 44.37: {window} default: window=speed dependent
   2693 +
   2694 +The number of lines in a text window in the visual command.  The default is 8
   2695 +at slow speeds (600 baud or less), 16 at medium speed (1200 baud), and the full
   2696 +screen (minus one line) at higher speeds.
   2697 +
   2698 +Section 44.38: {wrapscan}, {ws} default: ws
   2699 +
   2700 +Searches using the regular expressions in addressing will wrap around past the
   2701 +end of the file.
   2702 +
   2703 +Section 44.39: {wrapmargin}, {wm} default: wm=0
   2704 +
   2705 +Defines a margin for automatic wrapover of text during input in open and visual
   2706 +modes.  The numeric value is the number of columns from the right edge of the
   2707 +screen around which vi looks for a convenient place to insert a new-line
   2708 +character (wm=0 is OFF).  This is very convenient for touch typists.
   2709 +Wrapmargin behaves much like fill/nojustify mode does in nroff.
   2710 +
   2711 +Section 44.40: {writeany}, {wa} default: nowa
   2712 +
   2713 +Inhibit the checks normally made before write commands, allowing a write to any
   2714 +file which the system protection mechanism will allow.
   2715 +
   2716 +Section 44.41: {w300}, {w1200}, {w9600} defaults: w300=8
   2717 +                                                 w1200=16
   2718 +                                                 w9600=full screen minus one
   2719 +
   2720 +These are not true options but set the default size of the window for when the
   2721 +speed is slow (300), medium (1200), or high (9600), respectively.  They are
   2722 +suitable for an EXINIT and make it easy to change the 8/16/full screen rule.
   2723 +
   2724 +Section 45: Limitations
   2725 +
   2726 +Here are some editor limits that the user is likely to encounter:
   2727 +       1024   characters per line
   2728 +       256    characters per global command list
   2729 +       128    characters per file name
   2730 +       128    characters in the previous inserted and deleted text in open or 
   2731 +              visual
   2732 +       100    characters in a shell escape command
   2733 +       63     characters in a string valued option
   2734 +       30     characters in a tag name
   2735 +       250000 lines in the file (this is silently enforced).
   2736 +
   2737 +The visual implementation limits the number of macros defined with map to 32,
   2738 +and the total number of characters in macros to be less than 512.
   2739 +
   2740 +[Editor's note: these limits may not apply to versions after 4.1BSD.]
   2741 diff -Naur nvi-1.81.orig/nvi-1.79/docs/tutorial/vi.beginner nvi-1.81.6/nvi-1.79/docs/tutorial/vi.beginner
   2742 --- nvi-1.81.6.orig/nvi-1.79/docs/tutorial/vi.beginner	1970-01-01 01:00:00.000000000 +0100
   2743 +++ nvi-1.81.6/nvi-1.79/docs/tutorial/vi.beginner	2008-06-22 20:35:35.000000000 +0200
   2744 @@ -0,0 +1,741 @@
   2745 +Section 1: {^F} {ZZ}
   2746 +
   2747 +To get out of this tutorial, type: ZZ (two capital Z's).
   2748 +
   2749 +Learning a new computer system implies learning a new text editor.  These
   2750 +tutorial lessons were created by Dain Samples to help you come to grips with
   2751 +UC Berkeley's screen oriented editor called vi (for VIsual). This tutorial
   2752 +uses the vi editor itself as the means of presentation. 
   2753 +
   2754 +For best use of this tutorial, read all of a screen before performing any of
   2755 +the indicated actions.  This tutorial (or, at least, the first half of it) has
   2756 +been designed to systematically present the vi commands IF THE INSTRUCTIONS
   2757 +ARE FOLLOWED!  If you are too adventuresome, you may find yourself lost.  If
   2758 +you ever find yourself stuck, remember the first line of this section.
   2759 +
   2760 +OK, now find the control key on your keyboard; it usually has CTL or CTRL
   2761 +written on its upper surface.  Your first assignment is to hold the control
   2762 +key down while you press the 'F' key on your keyboard.  Please do so now.
   2763 +
   2764 +
   2765 +
   2766 +Section 2: {^F} {^B}
   2767 +Many of vi's commands use the control key and some other key in combination,
   2768 +as with the control and the 'F' key above.  This is abbreviated CTL-F, or ^F.
   2769 +
   2770 +As you have probably guessed by now, ^F (CTL-F) moves you forward a fixed
   2771 +number of lines in the file.  Throughout the remainder of the tutorial when
   2772 +you are ready to advance to the next section of text, hit ^F.
   2773 +
   2774 +The opposite command is ^B.  Just for fun, you might want to try a ^B to see
   2775 +the previous section again.  Be sure to do a ^F to return you here.
   2776 +
   2777 +Determine what the cursor looks like on your screen.  Whatever it is (a box,
   2778 +an underscore, blinking, flashing, inverse, etc.) it should now be positioned
   2779 +in the upper left-hand corner of your screen under or on the S of Section.
   2780 +Become familiar with your cursor: to use vi correctly it is important to
   2781 +always know where the cursor is.
   2782 +
   2783 +Did you notice that when you do a ^F the cursor is left at the top of the
   2784 +screen, and a ^B leaves the cursor near the bottom of the screen?  Try the two
   2785 +commands ^B^F again.  And now do another ^F to see the next section.
   2786 +
   2787 +Section 3: {^F} {^B}
   2788 +You now have two basic commands for examining a file, both forwards (^F) and
   2789 +backwards (^B).
   2790 +
   2791 +Note that these are vi text editing commands: they are not commands for the
   2792 +tutorial.  Indeed, this tutorial is nothing but a text file which you are now
   2793 +editing.  Everything you do and learn in this tutorial will be applicable to
   2794 +editing text files.
   2795 +
   2796 +Therefore, when you are editing a file and are ready to see more of the text,
   2797 +entering ^F will get you to the next section of the file.  Entering ^B will
   2798 +show you the previous section.
   2799 +
   2800 +Time for you to do another ^F.
   2801 +
   2802 +
   2803 +
   2804 +
   2805 +
   2806 +
   2807 +
   2808 +Section 4: {^F} {^B} {^M} (return key)
   2809 +We will adopt the notation of putting commands in curly braces so we can write
   2810 +them unambiguously.  For example, if you are to type the command sequence
   2811 +"control B control F" (as we asked you to do above) it would appear as {^B^F}.
   2812 +This allows clear delineation of the command strings from the text. Remember
   2813 +that the curly braces are NOT part of the command string you are to type. Do
   2814 +NOT type the curly braces.  
   2815 +
   2816 +Sometimes, the command string in the curly braces will be rather long, and may
   2817 +be such that the first couple of characters of the command will erase from
   2818 +the screen the string you are trying to read and type.  It is suggested that
   2819 +you write down the longer commands BEFORE you type them so you won't forget
   2820 +them once they disappear.
   2821 +
   2822 +Now locate the return key on your keyboard: it is usually marked 'RETURN',
   2823 +indicate hitting the return key.  In fact, the control-M key sequence is
   2824 +exactly the same as if you hit the return key, and vice versa.
   2825 +
   2826 +Now type {^F}.
   2827 +
   2828 +
   2829 +Section 5: {:q!} {ZZ} {^M} (return key)
   2830 +Recognize that this tutorial is nothing more than a text file that you
   2831 +are editing.  This means that if you do something wrong, it is possible
   2832 +for you to destroy the information in this file.  Don't worry.  If this
   2833 +happens, type {ZZ} (two capital Z's) or {:q!^M} to leave the tutorial.
   2834 +Restart the tutorial.  Once in the tutorial, you can then page forward
   2835 +with {^F} until you are back to where you want to be.  (There are
   2836 +easier ways to do this, some of which will be discussed later, but this
   2837 +is the most straightforward.)
   2838 +
   2839 +You may want to write these commands down in a convenient place for quick
   2840 +reference: {:q!^M} and {ZZ}
   2841 +
   2842 +We will assume that you now know to do a {^F} to advance the file
   2843 +
   2844 +
   2845 +
   2846 +
   2847 +
   2848 +
   2849 +
   2850 +Section 6: {m} {G} {'} {z}
   2851 +Now that you know how to get around in the file via ^F and ^B let's look at
   2852 +other ways of examining a text file.  Sometimes it is necessary, in the midst
   2853 +of editing a file, to examine another part of the file.  You are then faced
   2854 +with the problem of remembering your place in the file, looking at the other
   2855 +text, and then getting back to your original location.  Vi has a 'mark'
   2856 +command, m. Type {mp}.  You have just 'marked' your current location in the
   2857 +file and given it the name 'p'.  The command string below will do three
   2858 +things: position you at the beginning of the file (line 1), then return you to
   2859 +the location 'p' that you just marked with the 'm' command, and, since the
   2860 +screen will not look exactly the same as it does right now, the 'z' command
   2861 +will reposition the screen. (You may want to write the string down before
   2862 +typing it: once you type {1G} it will no longer be on the screen.)
   2863 +
   2864 +So now type {1G'pz^M} - a one followed by a capital G, followed by the quote
   2865 +mark, followed by a lower case 'p', then a lower case 'z', then a return
   2866 +(which is the same as a ^M).  The {1G} moves you to line 1, i.e. the beginning
   2867 +of the file.  The {'p} moves you to the location you marked with {mp}.  The
   2868 +{z^M} command will repaint the screen putting the cursor at the top of the
   2869 +screen. (Now {^F}.)
   2870 +
   2871 +Section 7: {m} {G} {'} {z}
   2872 +Let's look at some variations on those commands.  If you wanted to look at
   2873 +line 22 in the file and return to this location you could type {mp22G'p}.  Do
   2874 +so now, observing that {22G} puts your cursor at the beginning of section 2 in
   2875 +the middle of the screen.
   2876 +
   2877 +Also note that, without the {z^M} command, the line with 'Section 7' on it is
   2878 +now in the MIDDLE of the screen, and not at the top.  Our cursor is on the
   2879 +correct line (where we did the {mp} command) but the line is not where we
   2880 +might like it to be on the screen.  That is the function of the {z^M} command.
   2881 +(Remember, ^M is the same as the 'return' key on your keyboard.)  Type {z^M}
   2882 +now and observe the effect.
   2883 +
   2884 +As you can see, the 'Section 7' line is now at the top of the screen with the
   2885 +cursor happily under the capital S.  If you would like the cursor line (i.e.
   2886 +the line which the cursor is on) in the middle of the screen again, you would
   2887 +type {z.}.  If you wanted the cursor line to be at the BOTTOM of the screen,
   2888 +type {z-}.  Try typing {z-z.z^M} and watch what happens.
   2889 +
   2890 +{^F}
   2891 +
   2892 +Section 8: {z} {m} {'}
   2893 +
   2894 +Note that the z command does not change the position of our cursor in the file
   2895 +itself, it simply moves the cursor around on the screen by moving the contents
   2896 +of the file around on the screen.  The cursor stays on the same line of the
   2897 +file when using the z command.
   2898 +
   2899 +This brings up an important point.  There are two questions that the users of
   2900 +vi continually need to know the answer to: "Where am I in the file?" and
   2901 +"Where am I on the screen?"  The cursor on your terminal shows the answer to
   2902 +both questions.  Some commands will move you around in the file, usually
   2903 +changing the location of the cursor on the screen as well.  Other commands
   2904 +move the cursor around on the screen without changing your location in the
   2905 +file.
   2906 +
   2907 +Now type {ma}.  Your location in the file has been given the name 'a'. If you
   2908 +type {'p'a} you will see the previous location we marked in section 7, and
   2909 +then will be returned to the current location.  (You will want to do a {z^M}
   2910 +to repaint the screen afterwards.)  Try it.  
   2911 +{^F}
   2912 +
   2913 +Section 9: {m} {''}
   2914 +Now we can move about in our file pretty freely.  By using the {m} command we
   2915 +can give the current cursor position a lower-case-character name, like 'p',
   2916 +'a', 'e', 'm', or 'b'.  Using the {G} command preceded by a line number we can
   2917 +look at any line in the file we like.  Using the single quote command {'}
   2918 +followed by a character used in an {m} command, we can return to any location
   2919 +in the file we have marked.
   2920 +
   2921 +However, try {m3}, or {mM}.  You should hear a beep, or bell.  Only lower-case
   2922 +letters are acceptable to the {m} and {'} commands: numbers, upper-case
   2923 +letters, and special characters are not acceptable.
   2924 +
   2925 +If you type the {'} command with a character that is lower-case alphabetic but
   2926 +that has not been used in an {m} command, or for which the 'marked' text has
   2927 +been deleted, you will also get a beep.  Try {'i}.  You should get a beep
   2928 +because the command {mi} has never been issued.  (Unless you've been
   2929 +experimenting.)
   2930 +
   2931 +The command {''} attempts to return you to the location at which you last
   2932 +modified some part of your file.  However, my experience has been that it is
   2933 +difficult to predict exactly where you will end up.  
   2934 +Section 10: {^M} {-}
   2935 +Now do {ma}, marking your position at the top of the screen.  Now hit {^M} (or
   2936 +return) until the cursor is right ... 
   2937 +* <- here, over/under the asterisk.  Now
   2938 +type {mb'a'b} and watch the cursor move from the asterisk to the top of the
   2939 +screen and back again.
   2940 +
   2941 +The {^M} command moves the cursor to the beginning of the next line.  Now type
   2942 +{^M} until the cursor is right ...
   2943 +* <- here.  The command to move the cursor to the beginning of the
   2944 +previous line is {-}.  Practice moving the cursor around on the screen by using
   2945 +{^M} and {-}.  BE CAREFUL to not move the cursor OFF the screen just yet.  If
   2946 +you do, type {'az^M}.
   2947 +
   2948 +Now we can move to any line within the screen.  Practice moving around in the
   2949 +file using the {^F}, {^B}, {-}, {^M}, {z}, and {'} commands.  When you are
   2950 +fairly confident that you can get to where you need to be in the file, and
   2951 +position the cursor on the screen where you want it type {'az^M^F} (which, of
   2952 +course, moves you back to the beginning of this section, repositions the
   2953 +cursor at the top of the screen, and advances you to the next section).
   2954 +
   2955 +Section 11: scrolling: {^M}
   2956 +The cursor should now be on the S of 'Section 11', and this should be on the
   2957 +first line of the screen.  If it is not, do {^M} or {-} as appropriate to put
   2958 +the cursor on the section line, and type {z^M}.
   2959 +
   2960 +Type {mc} to mark your place.
   2961 +
   2962 +Now type {^M} until the cursor is on the last line of this screen.  Now do one
   2963 +more {^M} and observe the result.  This is called scrolling.  When you
   2964 +attempted to move to a line not displayed on the screen, the line at the top of
   2965 +the screen was 'scrolled off', and a line at the bottom of the screen was
   2966 +'scrolled on'.  The top line with 'Section 11' should no longer be visible.
   2967 +
   2968 +Now type {'cz^M} to reset the screen and type {^F} for the next section.
   2969 +
   2970 +
   2971 +
   2972 +
   2973 +
   2974 +
   2975 +
   2976 +Section 12: {-} {z}
   2977 +
   2978 +The {-} command moves the cursor to the previous line in the file.  Now type
   2979 +{-}, which attempts to move the cursor to the previous line in this file.
   2980 +However, that line is not on the screen.  The resulting action will depend on
   2981 +your terminal.  (Do a {^Mz^M} to reposition the file).  On intelligent
   2982 +terminals (e.g. VT100s, Z19s, Concept 100s), a top line is 'scrolled on' and
   2983 +the bottom line is 'scrolled off'.  Other terminals, however, may not have
   2984 +this 'reverse scrolling' feature.  They will simply repaint the screen with
   2985 +the cursor line in the middle of the screen.  On such terminals it is
   2986 +necessary to type {z^M} to get the cursor line back to the top of the screen.
   2987 +
   2988 +
   2989 +
   2990 +
   2991 +
   2992 +
   2993 +
   2994 +
   2995 +
   2996 +
   2997 +Section 13:
   2998 +Up until this point, the tutorial has always tried to make sure that the first
   2999 +line of each screen has on it the section number and a list of the commands
   3000 +covered in that section.  This will no longer be strictly maintained.  If you
   3001 +want the section line at the top of the screen, you now know enough commands to
   3002 +do it easily: do {^M} or {-} until the cursor is on the section line and
   3003 +then {z^M}.  Also, from this point on, it may not be the case that a {^F} will
   3004 +put you at the beginning of the next section.  Therefore, be aware of where you
   3005 +are in the file as we look at other commands.  You may have to find your way
   3006 +back to a particular section without any help from the tutorial.  If you do not
   3007 +feel comfortable with this, then it is suggested that you practice moving from
   3008 +section 1 to section 13, back and forth, using {^M}, {-}, {^F}, and {^B}
   3009 +commands for a while.
   3010 +
   3011 +Also make liberal use of the mark command {m}: if, for example, you make a
   3012 +habit of using {mz} to mark your current location in the file, then you will
   3013 +always be able to return to that location with {'z} if the editor does
   3014 +something strange and you have no idea where you are or what happened.
   3015 +
   3016 +And finally, the proscription against experimentation is hereby lifted: play
   3017 +with the editor.  Feel free to try out variations on the commands and move
   3018 +around in the file.  By this time you should be able to recover from any gross
   3019 +errors.
   3020 +
   3021 +Section 14: {^E} {^Y} {^D} {^U}
   3022 +Let us now look at a few other commands for moving around in the file, and
   3023 +moving the file around on the screen.  Note that the commands we have already
   3024 +looked at are sufficient: you really don't need any more commands for looking
   3025 +in a file.  The following commands are not absolutely necessary.  However,
   3026 +they can make editing more convenient, and you should take note of their
   3027 +existence.  But it would be perfectly valid to decide to ignore them on this
   3028 +first pass: you can learn them later when you see a need for them, if you ever
   3029 +do.
   3030 +
   3031 +First, let's clear up some potentially confusing language.  In at least one
   3032 +place in the official document ('An Introduction to Display Editing with Vi'
   3033 +by William Joy, and Mark Horton, September 1980), the expression "to scroll
   3034 +down text" means that the cursor is moved down in your file.  However, note
   3035 +that this may result in the text on the screen moving UP.  This use of the
   3036 +word 'scroll' refers to the action of the cursor within the file.  However,
   3037 +another legitimate use of the word refers to the action of the text on the
   3038 +screen.  That is, if the lines on your screen move up toward the top of the
   3039 +screen, this would be 'scrolling the screen up'.  If the lines move down
   3040 +toward the bottom of the screen, this would be refered to as scrolling down.
   3041 +
   3042 +I have tried to maintain the following jargon: 'scrolling' refers to what the
   3043 +text does on the screen, not to what the cursor does within the file.  For the
   3044 +latter I will refer to the cursor 'moving', or to 'moving the cursor'.  I
   3045 +realize that this is not necessarily consistent with Joy and Horton, but they
   3046 +were wrong.
   3047 +
   3048 +{^E} scrolls the whole screen up one line, keeping the cursor on the same line,
   3049 +if possible.  However, if the cursor line is the first line on the screen, then
   3050 +the cursor is moved to the next line in the file.  Try typing {^E}.
   3051 +
   3052 +{^Y} scrolls the screen down one line, keeping the cursor on the same line, if
   3053 +possible.  However, if the cursor line is the last line on the screen, then the
   3054 +cursor is moved to the previous line in the file.  Try it.
   3055 +
   3056 +{^D} moves the cursor down into the file, scrolling the screen up.
   3057 +
   3058 +{^U} moves the cursor up into the file, also scrolling the screen if the
   3059 +terminal you are on has the reverse scroll capability.  Otherwise the
   3060 +screen is repainted.
   3061 +
   3062 +Note that {^E} and {^Y} move the cursor on the screen while trying to keep the
   3063 +cursor at the same place in the file (if possible: however, the cursor can
   3064 +never move off screen), while {^D} and {^U} keep the cursor at the same place
   3065 +on the screen while moving the cursor within the file.
   3066 +
   3067 +Section 15: {/ .. /^M}
   3068 +
   3069 +Another way to position yourself in the file is by giving the editor a string
   3070 +to search for.  Type the following: {/Here 1/^M} and the cursor should end up
   3071 +right ...........................here ^.  Now type {/Section 15:/^M} and the
   3072 +cursor will end up over/on .....................here ^.  Now type {//^M} and
   3073 +observe that the cursor is now over the capital S five lines above this line.
   3074 +Typing {//^M} several more times will bounce the cursor back and forth between
   3075 +the two occurrences of the string.  In other words, when you type a string
   3076 +between the two slashes, it is searched for.  Typing the slashes with nothing
   3077 +between them acts as if you had typed the previous string again.
   3078 +
   3079 +Observe that the string you type between the two slashes is entered on the
   3080 +bottom line of the screen.  Now type {/Search for x /^M} except replace the 'x'
   3081 +in the string with some other character, say 'b'.  The message "Pattern not
   3082 +found" should appear on the bottom of the screen.  If you hadn't replaced the
   3083 +'x', then you would have found the string.  Try it.
   3084 +
   3085 +Section 16: {? .. ?^M} {n} (search strings: ^ $)
   3086 +
   3087 +When you surround the sought-for string with slashes as in {/Search/}, the
   3088 +file is searched beginning from your current position in the file.  If the
   3089 +string is not found by the end of the file, searching is restarted at the
   3090 +beginning of the file.  However, if you do want the search to find the
   3091 +PREVIOUS rather than the NEXT occurrence of the string, surround the string
   3092 +with question marks instead of slash marks.
   3093 +
   3094 +Below are several occurrences of the same string.  
   3095 +Here 2            Here 2 Here 2
   3096 + Here 2             Here 2.
   3097 +Observe the effect of the following search commands (try them in the
   3098 +sequence shown):
   3099 +{/Here 2/^M}  {//^M}  {??^M}
   3100 +{/^Here 2/^M}  {//^M}  {??^M}
   3101 +{/Here 2$/^M}  {//^M}  {??^M}
   3102 +
   3103 +The first command looks for the next occurrence of the string 'Here 2'.
   3104 +However the second line of commands looks for an occurrence of 'Here 2' that
   3105 +is at the beginning of the line.  When the up-arrow is the first character of
   3106 +a search string it stands for the beginning of the line.  When the dollar-sign
   3107 +is the last character of the search string it stands for the end of the line.
   3108 +Therefore, the third line of commands searches for the string only when it is
   3109 +at the end of the line.  Since there is only one place the string begins a
   3110 +line, and only one place the string ends the line, subsequent {//^M} and
   3111 +{??^M} will find those same strings over and over.
   3112 +
   3113 +The {n} command will find the next occurrence of the / or ? search
   3114 +string.  Try {/Here 2/^M} followed by several {n} and observe the
   3115 +effect.  Then try {??^M} followed by several {n}.  The {n} command
   3116 +remembers the direction of the last search.  It is just a way to save a
   3117 +few keystrokes.
   3118 +
   3119 +Section 17: \ and magic-characters in search strings
   3120 +
   3121 +Now type {/Here 3$/^M}.  You might expect the cursor to end up
   3122 +right......^ here.  However, you will get "Pattern not found" at the bottom of
   3123 +the screen.  Remember that the dollar-sign stands for the end of the line.
   3124 +Somehow, you must tell vi that you do not want the end of the line, but a
   3125 +dollar-sign.  In other words, you must take away the special meaning that the
   3126 +dollar-sign has for the search mechanism.  You do this (for any special
   3127 +character, including the up-arrow ^) by putting a back-slash ('\', not '/') in
   3128 +front of the character.
   3129 +
   3130 +Now try {/Here 3\$/^M} and you should end up nine lines above this one.  Try
   3131 +{//^M} and note that it returns you to the same place, and not to the first
   3132 +line of this paragraph: the back-slash character is not part of the search
   3133 +string and will not be found.  To find the string in the first line of this
   3134 +paragraph, type {/Here 3\\\$/^M}.  There are three back-slashes: the first takes
   3135 +away the special meaning from the second, and the third takes away the special
   3136 +meaning from the dollar-sign.
   3137 +
   3138 +Following is a list of the characters that have special meanings in search
   3139 +strings.  If you wish to find a string containing one of these characters, you
   3140 +will have to be precede the character with a backslash.  These characters are
   3141 +called magic characters because of the fun and games you can have with them
   3142 +and they can have with you, if you aren't aware of what they do.  
   3143 +
   3144 +  ^ - (up-arrow)       beginning of a line
   3145 +  $ - (dollar-sign)    end of a line
   3146 +  . - (period)         matches any character
   3147 +  \ - (backslant)      the escape character itself
   3148 +  [ - (square bracket) for finding patterns (see section #SEARCH)
   3149 +  ] - (square bracket) ditto
   3150 +  * - (asterisk)       ditto
   3151 +
   3152 +Without trying to explain it here, note that {:set nomagic^M} turns off the
   3153 +special meanings of all but the ^ up-arrow, $ dollar-sign, and backslash
   3154 +characters.
   3155 +
   3156 +Section 18: {: (colon commands)} {ZZ}
   3157 +
   3158 +In this section we will discuss getting into and out of the editor in more
   3159 +detail.  If you are editing a file and wish to save the results the command
   3160 +sequence {:w^M} writes the current contents of the file out to disk, using the
   3161 +file name you used when you invoked the editor.  That is, if you are at the
   3162 +command level in Unix, and you invoke vi with {vi foo} where foo is the name
   3163 +of the file you wish to edit, then foo is the name of the file used by the
   3164 +{:w^M} command.
   3165 +
   3166 +If you are done, the write and quit commands can be combined into a single
   3167 +command {:wq^M}.  An even simpler way is the command {ZZ} (two capital Z's).
   3168 +
   3169 +If, for some reason, you wish to exit without saving any changes you have made,
   3170 +{:q!^M} does the trick.  If you have not made any changes, the exclamation
   3171 +point is not necessary: {:q^M}.  Vi is pretty good about not letting you
   3172 +get out without warning you that you haven't saved your file.
   3173 +
   3174 +We have mentioned before that you are currently in the vi editor, editing a
   3175 +file.  If you wish to start the tutorial over from the very beginning, you
   3176 +could {ZZ}, and then type {vi.tut beginner} in response to the Unix prompt.
   3177 +This will create a fresh copy of this file for you, which might be necessary 
   3178 +if you accidentally destroyed the copy you were working with.  Just do a 
   3179 +search for the last section you were in: e.g.  {/Section 18:/^Mz^M}.
   3180 +
   3181 +Section 19: {H} {M} {L}
   3182 +
   3183 +Here are a few more commands that will move you around on the screen.  Again,
   3184 +they are not absolutely necessary, but they can make screen positioning easier:
   3185 +
   3186 +{H} - puts the cursor at the top of the screen (the 'home' position)
   3187 +
   3188 +{M} - puts the cursor in the middle of the screen
   3189 +
   3190 +{L} - puts the cursor at the bottom of the screen.
   3191 +
   3192 +Try typing {HML} and watch the cursor.
   3193 +
   3194 +Try typing {5HM5L} and note that 5H puts you five lines from the top of the
   3195 +screen, and 5L puts you five lines from the bottom of the screen.
   3196 +
   3197 +Section 20: {w} {b} {0} {W} {B} {e} {E} {'} {`}
   3198 +
   3199 +Up to this point we have concentrated on positioning in the file, and
   3200 +positioning on the screen.  Now let's look at positioning in a line.  Put the
   3201 +cursor at the beginning of the following line and type {z^M}:
   3202 +
   3203 +This is a test line: your cursor should initially be at its beginning.
   3204 +
   3205 +The test line should now be at the top of your screen. Type {w} several times.
   3206 +Note that it moves you forward to the beginning of the next word.  Now type
   3207 +{b} (back to the beginning of the word) several times till you are at the
   3208 +beginning of the line.  (If you accidentally type too many {b}, type {w} until
   3209 +you are on the beginning of the line again.) Type {wwwww} (five w's) and note
   3210 +that the cursor is now on the colon in the sentence.  The lower-case w command
   3211 +moves you forward one word, paying attention to certain characters such as
   3212 +colon and period as delimiters and counting them as words themselves.  Now
   3213 +type {0} (zero, not o 'oh'): this moves you to the beginning of the current
   3214 +line.  Now type {5w} and notice that this has the effect of repeating {w} five
   3215 +times and that you are now back on the colon.  Type {0} (zero) again.  To
   3216 +ignore the delimiters and to move to the beginning of the next word using only
   3217 +blanks, tabs and carriage-returns (these are called white-space characters) to
   3218 +delimit the words, use the {W} command: upper-case W.  {B} takes you back a
   3219 +word using white-space characters as word delimiters.
   3220 +
   3221 +Note that the commands {wbWB} do not stop at the beginning or end of a line:
   3222 +they will continue to the next word on the next line in the direction specified
   3223 +(a blank line counts as a word).
   3224 +
   3225 +If you are interested in the END of the word, and not the BEGINNING, then use
   3226 +the {e} and {E} commands.  These commands only move forward and there are no
   3227 +corresponding 'reverse search' commands for the end of a word.
   3228 +
   3229 +Also, we have been using the {'} command to move the cursor to a position that
   3230 +we have previously marked with the {m} command.  However, position the cursor
   3231 +in the middle of a line (any line, just pick one) and type {mk}, marking that
   3232 +position with the letter k.  Now type a few returns {^M} and type {'k}.
   3233 +Observe that the cursor is now at the beginning of the line that you marked.
   3234 +Now try {`k}: note that this is the reverse apostrophe, or back-quote, or grave
   3235 +accent, or whatever you want to call it.  Also note that it moves you to the
   3236 +character that was marked, not just to the line that was marked.
   3237 +
   3238 +In addition, the {``} command works just like the {''} command except that you
   3239 +are taken to the exact character, not just to the line.  (I'm still not
   3240 +sure which exact character, just as I'm still not sure which line.)
   3241 +
   3242 +Section 21: {l} {k} {j} {h}
   3243 +
   3244 +There are several commands to move around on the screen on a character by
   3245 +character basis:
   3246 +
   3247 +l - moves the cursor one character to the RIGHT
   3248 +k - moves the cursor UP one line
   3249 +j - moves the cursor DOWN one line
   3250 +h - moves the cursor one character to the LEFT
   3251 +
   3252 +Section 22: {i} {a} {I} {A} {o} {O} ^[ (escape key)
   3253 +
   3254 +For this and following sections you will need to use the ESCAPE key on your
   3255 +terminal.  It is usually marked ESC.  Since the escape key is the same as
   3256 +typing {^[} we will use ^[ for the escape key.
   3257 +
   3258 +Probably the most often used command in an editor is the insert command.  Below
   3259 +are two lines of text, the first correct, the second incorrect.  Position your
   3260 +cursor at the beginning of Line 1 and type {z^M}.
   3261 +
   3262 +Line 1: This is an example of the insert command.
   3263 +Line 2: This is an of the insert command.
   3264 +
   3265 +To make line 2 look like line 1, we are going to insert the characters
   3266 +'example ' before the word 'of'.  So, now move the cursor so that it is
   3267 +positioned on the 'o' of 'of'.  (You can do this by typing {^M} to move
   3268 +to the beginning of line 2, followed by {6w} or {wwwwww} to position the cursor
   3269 +on the word 'of'.)
   3270 +
   3271 +Now carefully type the following string and observe the effects:
   3272 +  {iexample ^[}  (remember: ^[ is the escape key)}
   3273 +The {i} begins the insert mode, and 'example ' is inserted into the line: 
   3274 +be sure to notice the blank in 'example '.  The ^[ ends insertion mode, 
   3275 +and the line is updated to include the new string.  Line 1 should look exactly 
   3276 +like Line 2.
   3277 +
   3278 +Move the cursor to the beginning of Line 3 below and type {z^M}:
   3279 +
   3280 +Line 3: These lines are examples for the 'a' command.
   3281 +Line 4: These line are examples for the '
   3282 +
   3283 +We will change line four to look like line three by using the append command.
   3284 +We need to append an 's' to the word 'line'.  Position the cursor on the 'e'
   3285 +of 'line'.  You can do this in several ways, one way is the following:
   3286 +First, type {/line /^M}.  This puts us on the word 'line' in Line 4
   3287 +(the blank in the search string is important!).  Next, type {e}.  The 'e' puts
   3288 +us at the end of the word.  Now, type {as^[  (^[ is the escape character)}.  
   3289 +The 'a' puts us in insert mode, AFTER the current character.  We appended the 
   3290 +'s', and the escape ^[ ended the insert mode.
   3291 +
   3292 +The difference between {i} (insert) and {a} (append) is that {i} begins
   3293 +inserting text BEFORE the cursor, and {a} begins inserting AFTER the cursor.
   3294 +
   3295 +Now type {Aa' command.^[}.  The cursor is moved to the end of the line and the
   3296 +string following {A} is inserted into the text.  Line 4 should now look like
   3297 +line 3.
   3298 +
   3299 +Just as {A} moves you to the end of the line to begin inserting, {I} would
   3300 +begin inserting at the FRONT of the line.
   3301 +
   3302 +To begin the insertion of a line after the cursor line, type {o}.  To insert a
   3303 +line before the cursor line, type {O}.  In other words {o123^[} is equivalent
   3304 +to {A^M123^[}, and {O123^[} is equivalent to {I123^M^[}.  The text after the
   3305 +{o} or {O} is ended with an escape ^[.
   3306 +
   3307 +This paragraph contains information that is terminal dependent: you will just
   3308 +have to experiment to discover what your terminal does.  Once in the insert
   3309 +mode, if you make a mistake in the typing, ^H will delete the previous
   3310 +character up to the beginning of the current insertion.  ^W will delete the
   3311 +previous word, and one of ^U, @, or ^X will delete the current line (up to the
   3312 +beginning of the current insertion).  You will need to experiment with ^U, @,
   3313 +and ^X to determine which works for your terminal.
   3314 +
   3315 +Section 23: {f} {x} {X} {w} {l} {r} {R} {s} {S} {J}
   3316 +
   3317 +Position the cursor at the beginning of line 5 and {z^M}:
   3318 +
   3319 +Line 5: The line as it should be.
   3320 +Line 6: The line as it shouldn't be.
   3321 +
   3322 +To make Line 6 like Line 5, we have to delete the 'n', the apostrophe, and the
   3323 +'t'.  There are several ways to position ourselves at the 'n'.  Choose
   3324 +whichever one suits your fancy:
   3325 +
   3326 +{/n't/^M}
   3327 +{^M7w6l}  or  {^M7w6 } (note the space)
   3328 +{^M3fn}  (finds the 3rd 'n' on the line)
   3329 +
   3330 +Now {xxx} will delete the three characters, as will {3x}.
   3331 +
   3332 +Note that {X} deletes the character just BEFORE the cursor, as opposed
   3333 +to the character AT the cursor.
   3334 +
   3335 +Position the cursor at line 7 and {z^M}:
   3336 +
   3337 +Line 7: The line as it would be.
   3338 +Line 8: The line as it could be.
   3339 +
   3340 +To change line 8 into line 7 we need to change the 'c' in 'could' into a 'w'.
   3341 +The 'r' (replace) command was designed for this.  Typing {rc} is the same as
   3342 +typing {xic^[} (i.e.  delete the 'bad' character and insert the correct
   3343 +new character).  Therefore, assuming that you have positioned the cursor on the
   3344 +'c' of 'could', the easiest way to change 'could' into 'would' is {rw}.
   3345 +
   3346 +If you would like to now change the 'would' into 'should', use the substitute
   3347 +command, 's': {ssh^[}.  The difference between 'r' and 's' is that 'r'
   3348 +(replace) replaces the current character with another character, while 's'
   3349 +(substitute) substitutes the current character with a string, ended with an
   3350 +escape.
   3351 +
   3352 +The capital letter version of replace {R} replaces each character by a
   3353 +character one at a time until you type an escape, ^[.  The 'S' command
   3354 +substitutes the whole line.
   3355 +
   3356 +Position your cursor at the beginning of line 9 and {z^M}.
   3357 +
   3358 +Line  9: Love is a many splendored thing.
   3359 +Line 10: Love is a most splendored thing.
   3360 +
   3361 +To change line 10 into line 9, position the cursor at the beginning of 'most',
   3362 +and type {Rmany^[}.
   3363 +
   3364 +You may have noticed that, when inserting text, a new line is formed by typing
   3365 +{^M}.  When changing, replacing, or substituting text you can make a new line
   3366 +by typing {^M}.  However, neither {x} nor {X} will remove ^M to make two lines 
   3367 +into one line.  To do this, position the cursor on the first of the two lines 
   3368 +you wish to make into a single line and type {J} (uppercase J for 'Join').
   3369 +
   3370 +Section 24: {u} {U}
   3371 +
   3372 +Finally, before we review, let's look at the undo command.  Position
   3373 +your cursor on line 11 below and {z^M}.
   3374 +
   3375 +Line 11: The quick brown fox jumped over the lazy hound dog.
   3376 +Line 12: the qwick black dog dumped over the laxy poune fox.
   3377 +
   3378 +Type the following set of commands, and observe carefully the effect of each 
   3379 +of the commands:
   3380 +
   3381 +{/^Line 12:/^M} {ft} {rT} {fw} {ru} {w} {Rbrown fox^[} {w} {rj} 
   3382 +{fx} {rz} {w} {Rhound dog^[}
   3383 +
   3384 +Line 12 now matches line 11.  Now type {U} - capital 'U'.  And line 12 now
   3385 +looks like it did before you typed in the command strings.  Now type:
   3386 +
   3387 +{ft} {rT} {fw} {ru} {^M} {^M}
   3388 +
   3389 +and then type {u}:  the cursor jumps back to the line containing the second
   3390 +change you made and 'undoes' it.  That is, {U} 'undoes' all the changes on the
   3391 +line, and {u} 'undoes' only the last change.  Type {u} several times and
   3392 +observe what happens: {u} can undo a previous {u}!
   3393 +
   3394 +Caveat: {U} only works as long as the cursor is still on the line.  Move the
   3395 +cursor off the line and {U} will have no effect, except to possibly beep at
   3396 +you.  However, {u} will undo the last change, no matter where it occurred.
   3397 +
   3398 +Section 25: review
   3399 +
   3400 +At this point, you have all the commands you need in order to make use of vi.
   3401 +The remainder of this tutorial will discuss variations on these commands as
   3402 +well as introduce new commands that make the job of editing more efficient.
   3403 +Here is a brief review of the basic commands we have covered.  They are listed
   3404 +in the order of increasing complexity and/or decreasing necessity (to say that
   3405 +a command is less necessary is not to say that it is less useful!).  These
   3406 +commands allow you to comfortably edit any text file.  There are other
   3407 +commands that will make life easier but will require extra time to learn,
   3408 +obviously.  You may want to consider setting this tutorial aside for several
   3409 +weeks and returning to it later after gaining experience with vi and getting
   3410 +comfortable with it.  The convenience of some of the more exotic commands may
   3411 +then be apparent and worth the extra investment of time and effort
   3412 +required to master them.
   3413 +
   3414 +to get into the editor from Unix:           {vi filename}
   3415 +to exit the editor
   3416 +      saving all changes                    {ZZ} or {:wq^M}
   3417 +      throwing away all changes             {:q!^M}
   3418 +      when no changes have been made        {:q^M}
   3419 +save a file without exiting the editor      {:w^M}
   3420 +write the file into another file            {:w filename^M}
   3421 +insert text 
   3422 +      before the cursor                     {i ...text... ^[}
   3423 +      at the beginning of the line          {I ...text... ^[}
   3424 +      after the cursor (append)             {a ...text... ^[}
   3425 +      at the end of the line                {A ...text... ^[}
   3426 +      after the current line                {o ...text... ^[}
   3427 +      before the current line               {O ...text... ^[}
   3428 +delete the character  ...
   3429 +      under the cursor                      {x}
   3430 +      to the left of the cursor             {X}
   3431 +delete n characters                         {nx} or {nX}  (for n a number)
   3432 +make two lines into one line (Join)         {J}
   3433 +find a string in the file ...
   3434 +      searching forward                     {/ ...string... /^M}
   3435 +      searching backwards                   {? ...string... ?^M}
   3436 +repeat the last search command              {n}
   3437 +repeat the last search command in the
   3438 +  opposite direction                        {N}
   3439 +find the character c on this line ...
   3440 +      searching forward                     {fc}
   3441 +      searching backward                    {Fc}
   3442 +repeat the last 'find character' command    {;}
   3443 +replace a character with character x        {rx}
   3444 +substitute a single character with text     {s ...text... ^[}
   3445 +substitute n characters with text           {ns ...text... ^[}
   3446 +replace characters one-by-one with text     {R ...text... ^[}
   3447 +undo all changes to the current line        {U}
   3448 +undo the last single change                 {u}
   3449 +move forward in the file a "screenful"      {^F}
   3450 +move back in the file a "screenful"         {^B}
   3451 +move forward in the file one line           {^M} or {+}
   3452 +move backward in the file one line          {-}
   3453 +move to the beginning of the line           {0}
   3454 +move to the end of the line                 {$}
   3455 +move forward one word                       {w}
   3456 +move forward one word, ignoring punctuation {W}
   3457 +move forward to the end of the next word    {e}
   3458 +to the end of the word, ignoring punctuation{E}
   3459 +move backward one word                      {b}
   3460 +move back one word, ignoring punctuation    {B}
   3461 +return to the last line modified            {''}
   3462 +scroll a line onto the top of the screen    {^Y}
   3463 +scroll a line onto the bottom of the screen {^E}
   3464 +move "up" in the file a half-screen         {^U}
   3465 +move "down" in the file a half-screen       {^D}
   3466 +move the cursor to the top screen line      {H}
   3467 +move the cursor to the bottom screen line   {L}
   3468 +move the cursor to the middle line          {M}
   3469 +move LEFT one character position            {h} or {^H}
   3470 +move RIGHT one character position           {l} or { }
   3471 +move UP in the same column                  {k} or {^P}
   3472 +move DOWN in the same column                {j} or {^N}
   3473 +mark the current position, name it x        {mx}
   3474 +move to the line marked/named x             {'x}
   3475 +move to the character position named x      {`x}
   3476 +move to the beginning of the file           {1G}
   3477 +move to the end of the file                 {G}
   3478 +move to line 23 in the file                 {23G}
   3479 +repaint the screen with the cursor line
   3480 +       at the top of the screen             {z^M}
   3481 +       in the middle of the screen          {z.}
   3482 +       at the bottom of the screen          {z-}
   3483 +
   3484 +More information on vi can be found in the file vi.advanced, which you can
   3485 +peruse at your leisure.  From UNIX, type {vi.tut advanced^M}.