home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume41 / vim / part13 < prev    next >
Encoding:
Text File  |  1993-12-20  |  56.3 KB  |  1,913 lines

  1. Newsgroups: comp.sources.misc
  2. From: mool@oce.nl (Bram Moolenaar)
  3. Subject: v41i063:  vim - Vi IMitation editor, v2.0, Part13/25
  4. Message-ID: <1993Dec21.035111.28455@sparky.sterling.com>
  5. X-Md4-Signature: b81c881a9a1e55760b8c5c4a451bbc63
  6. Keywords: utility, editor, vi, vim
  7. Sender: kent@sparky.sterling.com (Kent Landfield)
  8. Organization: Sterling Software
  9. Date: Tue, 21 Dec 1993 03:51:11 GMT
  10. Approved: kent@sparky.sterling.com
  11.  
  12. Submitted-by: mool@oce.nl (Bram Moolenaar)
  13. Posting-number: Volume 41, Issue 63
  14. Archive-name: vim/part13
  15. Environment: UNIX, AMIGA, MS-DOS
  16. Supersedes: vim: Volume 37, Issue 1-24
  17.  
  18. #! /bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 13 (of 25)."
  25. # Contents:  vim/src/search.c vim/tutor/tutor
  26. # Wrapped by mool@oce-rd2 on Wed Dec 15 09:50:06 1993
  27. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  28. if test -f 'vim/src/search.c' -a "${1}" != "-c" ; then 
  29.   echo shar: Will not clobber existing file \"'vim/src/search.c'\"
  30. else
  31. echo shar: Extracting \"'vim/src/search.c'\" \(24021 characters\)
  32. sed "s/^X//" >'vim/src/search.c' <<'END_OF_FILE'
  33. X/* vi:ts=4:sw=4
  34. X *
  35. X * VIM - Vi IMproved
  36. X *
  37. X * Code Contributions By:    Bram Moolenaar            mool@oce.nl
  38. X *                            Tim Thompson            twitch!tjt
  39. X *                            Tony Andrews            onecom!wldrdg!tony
  40. X *                            G. R. (Fred) Walter     watmath!watcgl!grwalter
  41. X */
  42. X/*
  43. X * search.c: code for normal mode searching commands
  44. X */
  45. X
  46. X#include "vim.h"
  47. X#include "globals.h"
  48. X#include "proto.h"
  49. X#include "param.h"
  50. X#include "ops.h"        /* for mincl */
  51. X
  52. X/* modified Henry Spencer's regular expression routines */
  53. X#include "regexp.h"
  54. X
  55. Xstatic int inmacro __ARGS((char *, char *));
  56. Xstatic int cls __ARGS((void));
  57. X
  58. X/*
  59. X * This file contains various searching-related routines. These fall into
  60. X * three groups:
  61. X * 1. string searches (for /, ?, n, and N)
  62. X * 2. character searches within a single line (for f, F, t, T, etc)
  63. X * 3. "other" kinds of searches like the '%' command, and 'word' searches.
  64. X */
  65. X
  66. X/*
  67. X * String searches
  68. X *
  69. X * The string search functions are divided into two levels:
  70. X * lowest:    searchit(); called by dosearch() and docmdline().
  71. X * Highest: dosearch(); changes Curpos, called by normal().
  72. X *
  73. X * The last search pattern is remembered for repeating the same search.
  74. X * This pattern is shared between the :g, :s, ? and / commands.
  75. X * This is in myregcomp().
  76. X *
  77. X * The actual string matching is done using a heavily modified version of
  78. X * Henry Spencer's regular expression library.
  79. X */
  80. X
  81. Xstatic char     *search_pattern = NULL;  /* previous search pattern */
  82. Xstatic int        want_start;              /* looking for start of line? */
  83. X
  84. X/*
  85. X * translate search pattern for regcomp()
  86. X */
  87. X    regexp *
  88. Xmyregcomp(pat)
  89. X    char *pat;
  90. X{
  91. X    regexp *retval;
  92. X
  93. X    if (pat == NULL || *pat == NUL)     /* use previous search pattern */
  94. X    {
  95. X        if (search_pattern == NULL)
  96. X        {
  97. X            emsg(e_noprevre);
  98. X            return (regexp *) NULL;
  99. X        }
  100. X        pat = search_pattern;
  101. X    }
  102. X    else
  103. X    {
  104. X        if (search_pattern != NULL)
  105. X            free(search_pattern);
  106. X        search_pattern = strsave(pat);
  107. X        reg_magic = p_magic;        /* Magic sticks with the r.e. */
  108. X    }
  109. X    want_start = (*pat == '^');        /* looking for start of line? */
  110. X    reg_ic = p_ic;                /* tell the regexec routine how to search */
  111. X    retval = regcomp(pat);
  112. X    return retval;
  113. X}
  114. X
  115. X/*
  116. X * lowest level search function.
  117. X * Search for 'count'th occurrence of 'str' in direction 'dir'.
  118. X * Start at position 'pos' and return the found position in 'pos'.
  119. X * Return 1 for success, 0 for failure.
  120. X */
  121. X    int
  122. Xsearchit(pos, dir, str, count, end)
  123. X    FPOS    *pos;
  124. X    int     dir;
  125. X    char    *str;
  126. X    long    count;
  127. X    int        end;
  128. X{
  129. X    int             found;
  130. X    linenr_t        lnum;
  131. X    linenr_t        startlnum;
  132. X    regexp           *prog;
  133. X    register char  *s;
  134. X    char           *ptr;
  135. X    register int    i;
  136. X    register char  *match, *matchend;
  137. X    int             loop;
  138. X
  139. X    if ((prog = myregcomp(str)) == NULL)
  140. X    {
  141. X        emsg(e_invstring);
  142. X        return 0;
  143. X    }
  144. X/*
  145. X * find the string
  146. X */
  147. X    found = 1;
  148. X    while (count-- && found)    /* stop after count matches, or no more matches */
  149. X    {
  150. X        startlnum = pos->lnum;    /* remember start of search for detecting no match */
  151. X        found = 0;                /* default: not found */
  152. X
  153. X        i = pos->col + dir;     /* search starts one postition away */
  154. X        lnum = pos->lnum;
  155. X
  156. X        if (dir == BACKWARD)
  157. X        {
  158. X            if (i < 0)
  159. X                --lnum;
  160. X        }
  161. X
  162. X        for (loop = 0; loop != 2; ++loop)   /* do this twice if 'wrapscan' is set */
  163. X        {
  164. X            for ( ; lnum > 0 && lnum <= line_count; lnum += dir, i = -1)
  165. X            {
  166. X                s = ptr = nr2ptr(lnum);
  167. X                if (dir == FORWARD && i > 0)    /* first line for forward search */
  168. X                {
  169. X                    if (want_start || strlen(s) <= (size_t)i)   /* match not possible */
  170. X                        continue;
  171. X                    s += i;
  172. X                }
  173. X
  174. X                if (regexec(prog, s, dir == BACKWARD || i <= 0))
  175. X                {                            /* match somewhere on line */
  176. X                    match = prog->startp[0];
  177. X                    matchend = prog->endp[0];
  178. X                    if (dir == BACKWARD && !want_start)
  179. X                    {
  180. X                        /*
  181. X                         * Now, if there are multiple matches on this line, we have to
  182. X                         * get the last one. Or the last one before the cursor, if we're
  183. X                         * on that line.
  184. X                         */
  185. X                        while (regexec(prog, prog->startp[0] + 1, (int)FALSE))
  186. X                        {
  187. X                            if ((i >= 0) && ((prog->startp[0] - s) > i))
  188. X                                break;
  189. X                            match = prog->startp[0];
  190. X                            matchend = prog->endp[0];
  191. X                        }
  192. X
  193. X                        if ((i >= 0) && ((match - s) > i))
  194. X                            continue;
  195. X                    }
  196. X
  197. X                    pos->lnum = lnum;
  198. X                    if (end)
  199. X                        pos->col = (int) (matchend - ptr - 1);
  200. X                    else
  201. X                        pos->col = (int) (match - ptr);
  202. X                    found = 1;
  203. X                    break;
  204. X                }
  205. X                /* breakcheck is slow, do it only once in 16 lines */
  206. X                if ((lnum & 15) == 0)
  207. X                    breakcheck();       /* stop if ctrl-C typed */
  208. X                if (got_int)
  209. X                    break;
  210. X
  211. X                if (loop && lnum == startlnum)  /* if second loop stop where started */
  212. X                    break;
  213. X            }
  214. X    /* stop the search if wrapscan isn't set, after an interrupt and after a match */
  215. X            if (!p_ws || got_int || found)
  216. X                break;
  217. X
  218. X            if (dir == BACKWARD)    /* start second loop at the other end */
  219. X                lnum = line_count;
  220. X            else
  221. X                lnum = 1;
  222. X        }
  223. X        if (got_int)
  224. X            break;
  225. X    }
  226. X
  227. X    free((char *) prog);
  228. X
  229. X    if (!found)             /* did not find it */
  230. X    {
  231. X        if (got_int)
  232. X                emsg(e_interr);
  233. X        else
  234. X                emsg(e_patnotf);
  235. X        return 0;
  236. X    }
  237. X
  238. X    return 1;
  239. X}
  240. X
  241. X/*
  242. X * Highest level string search function.
  243. X * Search for the 'count'th occurence of string 'str' in direction 'dirc'
  244. X *                    If 'dirc' is 0: use previous dir.
  245. X * If 'str' is 0 or 'str' is empty: use previous string.
  246. X *              If 'reverse' is TRUE: go in reverse of previous dir.
  247. X *                 If 'echo' is TRUE: echo the search command
  248. X */
  249. X    int
  250. Xdosearch(dirc, str, reverse, count, echo)
  251. X    int                dirc;
  252. X    char           *str;
  253. X    int                reverse;
  254. X    long            count;
  255. X    int                echo;
  256. X{
  257. X    FPOS            pos;        /* position of the last match */
  258. X    char            *searchstr;
  259. X    static int        lastsdir = '/';    /* previous search direction */
  260. X    static int        lastoffline;/* previous/current search has line offset */
  261. X    static int        lastend;    /* previous/current search set cursor at end */
  262. X    static long     lastoff;    /* previous/current line or char offset */
  263. X    static int        nosetpm;    /* do not call setpcmark() */
  264. X    register char    *p;
  265. X    register long    c;
  266. X    char            *dircp = NULL;
  267. X
  268. X    if (dirc == 0)
  269. X        dirc = lastsdir;
  270. X    else
  271. X        lastsdir = dirc;
  272. X    if (reverse)
  273. X    {
  274. X        if (dirc == '/')
  275. X            dirc = '?';
  276. X        else
  277. X            dirc = '/';
  278. X    }
  279. X    searchstr = str;
  280. X                                    /* use previous string */
  281. X    if (str == NULL || *str == NUL || *str == dirc)
  282. X    {
  283. X        if (search_pattern == NULL)
  284. X        {
  285. X            emsg(e_noprevre);
  286. X            return 0;
  287. X        }
  288. X        searchstr = "";                /* will use search_pattern in myregcomp() */
  289. X    }
  290. X    if (str != NULL && *str != NUL)    /* look for (new) offset */
  291. X    {
  292. X        /* If there is a matching '/' or '?', toss it */
  293. X        for (p = str; *p; ++p)
  294. X        {
  295. X            if (*p == dirc)
  296. X            {
  297. X                dircp = p;        /* remember where we put the NUL */
  298. X                *p++ = NUL;
  299. X                break;
  300. X            }
  301. X            if (*p == '\\' && p[1] != NUL)
  302. X                ++p;    /* skip next character */
  303. X        }
  304. X
  305. X        lastoffline = FALSE;
  306. X        lastend = FALSE;
  307. X        nosetpm = FALSE;
  308. X        lastoff = 0;
  309. X        switch (*p)
  310. X        {
  311. X            case 'n':                     /* do not call setpcmark() */
  312. X                        nosetpm = TRUE;
  313. X                        ++p;
  314. X                        break;
  315. X            case '+':
  316. X            case '-':                   /* got a line offset */
  317. X                        lastoffline = TRUE;
  318. X                        break;
  319. X            case 'e':                   /* position cursor at end */
  320. X                        lastend = TRUE;
  321. X            case 's':                   /* got a character offset from start */
  322. X                        ++p;
  323. X        }
  324. X        if (*p == '+' || *p == '-')     /* got an offset */
  325. X        {
  326. X            if (isdigit(*(p + 1)))
  327. X                lastoff = atol(p);        /* '+nr' or '-nr' */
  328. X            else if (*p == '-')            /* single '-' */
  329. X                lastoff = -1;
  330. X            else                        /* single '+' */
  331. X                lastoff = 1;
  332. X            ++p;
  333. X            while (isdigit(*p))            /* skip number */
  334. X                ++p;
  335. X        }
  336. X        searchcmdlen = p - str;            /* compute lenght of search command
  337. X                                                        for get_address() */
  338. X    }
  339. X
  340. X    if (echo)
  341. X    {
  342. X        start_msg();
  343. X        outchar(dirc);
  344. X        outtrans(*searchstr == NUL ? search_pattern : searchstr, -1);
  345. X        if (lastoffline || lastend || lastoff || nosetpm)
  346. X        {
  347. X            outchar(dirc);
  348. X            if (nosetpm)
  349. X                outchar('n');
  350. X            else if (lastend)
  351. X                outchar('e');
  352. X            else if (!lastoffline)
  353. X                outchar('s');
  354. X            if (lastoff < 0)
  355. X            {
  356. X                outchar('-');
  357. X                outnum((long)-lastoff);
  358. X            }
  359. X            else if (lastoff > 0 || lastoffline)
  360. X            {
  361. X                outchar('+');
  362. X                outnum((long)lastoff);
  363. X            }
  364. X        }
  365. X        check_msg();
  366. X
  367. X        gotocmdline(FALSE, NUL);
  368. X        flushbuf();
  369. X    }
  370. X
  371. X    pos = Curpos;
  372. X
  373. X    c = searchit(&pos, dirc == '/' ? FORWARD : BACKWARD, searchstr, count, lastend);
  374. X    if (dircp)
  375. X        *dircp = dirc;        /* put second '/' or '?' back for normal() */
  376. X    if (!c)
  377. X        return 0;
  378. X
  379. X    if (!lastoffline)           /* add the character offset to the column */
  380. X    {
  381. X        if (lastoff > 0)        /* offset to the right, check for end of line */
  382. X        {
  383. X            p = pos2ptr(&pos) + 1;
  384. X            c = lastoff;
  385. X            while (c-- && *p++ != NUL)
  386. X                ++pos.col;
  387. X        }
  388. X        else                    /* offset to the left, check for start of line */
  389. X        {
  390. X            if ((c = pos.col + lastoff) < 0)
  391. X                c = 0;
  392. X            pos.col = c;
  393. X        }
  394. X    }
  395. X
  396. X    if (!nosetpm)
  397. X        setpcmark();
  398. X    Curpos = pos;
  399. X    set_want_col = TRUE;
  400. X
  401. X    if (!lastoffline)
  402. X        return 1;
  403. X
  404. X/*
  405. X * add the offset to the line number.
  406. X */
  407. X    c = Curpos.lnum + lastoff;
  408. X    if (c < 1)
  409. X        Curpos.lnum = 1;
  410. X    else if (c > line_count)
  411. X        Curpos.lnum = line_count;
  412. X    else
  413. X        Curpos.lnum = c;
  414. X    Curpos.col = 0;
  415. X
  416. X    return 2;
  417. X}
  418. X
  419. X
  420. X/*
  421. X * Character Searches
  422. X */
  423. X
  424. X/*
  425. X * searchc(c, dir, type, count)
  426. X *
  427. X * Search for character 'c', in direction 'dir'. If 'type' is 0, move to the
  428. X * position of the character, otherwise move to just before the char.
  429. X * Repeat this 'count' times.
  430. X */
  431. X    int
  432. Xsearchc(c, dir, type, count)
  433. X    int             c;
  434. X    register int    dir;
  435. X    int             type;
  436. X    long            count;
  437. X{
  438. X    static char     lastc = NUL;    /* last character searched for */
  439. X    static int        lastcdir;        /* last direction of character search */
  440. X    static int        lastctype;        /* last type of search ("find" or "to") */
  441. X    register int    col;
  442. X    char            *p;
  443. X    int             len;
  444. X
  445. X    if (c != NUL)       /* normal search: remember args for repeat */
  446. X    {
  447. X        lastc = c;
  448. X        lastcdir = dir;
  449. X        lastctype = type;
  450. X    }
  451. X    else                /* repeat previous search */
  452. X    {
  453. X        if (lastc == NUL)
  454. X            return FALSE;
  455. X        if (dir)        /* repeat in opposite direction */
  456. X            dir = -lastcdir;
  457. X        else
  458. X            dir = lastcdir;
  459. X    }
  460. X
  461. X    p = nr2ptr(Curpos.lnum);
  462. X    col = Curpos.col;
  463. X    len = strlen(p);
  464. X
  465. X    /*
  466. X     * On 'to' searches, skip one to start with so we can repeat searches in
  467. X     * the same direction and have it work right.
  468. X     * REMOVED to get vi compatibility
  469. X     * if (lastctype)
  470. X     *    col += dir;
  471. X     */
  472. X
  473. X    while (count--)
  474. X    {
  475. X            for (;;)
  476. X            {
  477. X                if ((col += dir) < 0 || col >= len)
  478. X                    return FALSE;
  479. X                if (p[col] == lastc)
  480. X                        break;
  481. X            }
  482. X    }
  483. X    if (lastctype)
  484. X        col -= dir;
  485. X    Curpos.col = col;
  486. X    return TRUE;
  487. X}
  488. X
  489. X/*
  490. X * "Other" Searches
  491. X */
  492. X
  493. X/*
  494. X * showmatch - move the cursor to the matching paren or brace
  495. X *
  496. X * Improvement over vi: Braces inside quotes are ignored.
  497. X */
  498. X    FPOS           *
  499. Xshowmatch()
  500. X{
  501. X    static FPOS        pos;            /* current search position */
  502. X    char            initc;            /* brace under or after the cursor */
  503. X    char            findc;            /* matching brace */
  504. X    char            c;
  505. X    int             count = 0;        /* cumulative number of braces */
  506. X    int             idx;
  507. X    static char     table[6] = {'(', ')', '[', ']', '{', '}'};
  508. X    int             inquote = 0;    /* non-zero when inside quotes */
  509. X    register char    *linep;            /* pointer to current line */
  510. X    register char    *ptr;
  511. X    int                do_quotes;        /* check for quotes in current line */
  512. X
  513. X    pos = Curpos;
  514. X
  515. X    /*
  516. X     * find the brace under or after the cursor
  517. X     */
  518. X    linep = nr2ptr(pos.lnum); 
  519. X    for (;;)
  520. X    {
  521. X        initc = linep[pos.col];
  522. X        if (initc == NUL)
  523. X            return (FPOS *) NULL;
  524. X
  525. X        for (idx = 0; idx < 6; ++idx)
  526. X            if (table[idx] == initc)
  527. X                break;
  528. X        if (idx != 6)
  529. X            break;
  530. X        ++pos.col;
  531. X    }
  532. X
  533. X    findc = table[idx ^ 1];        /* get matching brace */
  534. X    idx &= 1;
  535. X
  536. X    do_quotes = -1;
  537. X    while (!got_int)
  538. X    {
  539. X        /*
  540. X         * Go to the next position, forward or backward. We could use
  541. X         * inc() and dec() here, but that is much slower
  542. X         */
  543. X        if (idx)                          /* backward search */
  544. X        {
  545. X            if (pos.col == 0)           /* at start of line, go to previous one */
  546. X            {
  547. X                if (pos.lnum == 1)      /* start of file */
  548. X                    break;
  549. X                --pos.lnum;
  550. X                linep = nr2ptr(pos.lnum);
  551. X                pos.col = strlen(linep);    /* put pos.col on trailing NUL */
  552. X                do_quotes = -1;
  553. X            }
  554. X            else
  555. X                --pos.col;
  556. X        }
  557. X        else                            /* forward search */
  558. X        {
  559. X            if (linep[pos.col] == NUL)  /* at end of line, go to next one */
  560. X            {
  561. X                if (pos.lnum == line_count) /* end of file */
  562. X                    break;
  563. X                ++pos.lnum;
  564. X                linep = nr2ptr(pos.lnum);
  565. X                pos.col = 0;
  566. X                do_quotes = -1;
  567. X            }
  568. X            else
  569. X                ++pos.col;
  570. X        }
  571. X
  572. X        if (do_quotes == -1)        /* count number of quotes in this line */
  573. X        {
  574. X                /* we only do a breakcheck() once for every 16 lines */
  575. X            if ((pos.lnum & 15) == 0)
  576. X                breakcheck();
  577. X
  578. X            /*
  579. X             * count the number of quotes in the line, skipping \" and '"'
  580. X             */
  581. X            for (ptr = linep; *ptr; ++ptr)
  582. X                if (*ptr == '"' && (ptr == linep || ptr[-1] != '\\') &&
  583. X                            (ptr == linep || ptr[-1] != '\'' || ptr[1] != '\''))
  584. X                    ++do_quotes;
  585. X            do_quotes &= 1;            /* result is 1 with even number of quotes */
  586. X
  587. X            /*
  588. X             * If we find an uneven count, check current line and previous
  589. X             * one for a '\' at the end.
  590. X             */
  591. X            if (!do_quotes)
  592. X            {
  593. X                inquote = FALSE;
  594. X                if (ptr[-1] == '\\')
  595. X                {
  596. X                    do_quotes = 1;
  597. X                    if (idx)                    /* backward search */
  598. X                        inquote = TRUE;
  599. X                }
  600. X                if (pos.lnum > 1)
  601. X                {
  602. X                    ptr = nr2ptr(pos.lnum - 1);
  603. X                    if (*ptr && *(ptr + strlen(ptr) - 1) == '\\')
  604. X                    {
  605. X                        do_quotes = 1;
  606. X                        if (!idx)                /* forward search */
  607. X                            inquote = TRUE;
  608. X                    }
  609. X                }
  610. X            }
  611. X        }
  612. X
  613. X        /*
  614. X         * Things inside quotes are ignored by setting 'inquote'.
  615. X         * If we find a quote without a preceding '\' invert 'inquote'.
  616. X         * At the end of a line not ending in '\' we reset 'inquote'.
  617. X         *
  618. X         * In lines with an uneven number of quotes (without preceding '\')
  619. X         * we do not know which part to ignore. Therefore we only set
  620. X         * inquote if the number of quotes in a line is even,
  621. X         * unless this line or the previous one ends in a '\'.
  622. X         * Complicated, isn't it?
  623. X         */
  624. X        switch (c = linep[pos.col])
  625. X        {
  626. X        case NUL:
  627. X            inquote = FALSE;
  628. X            break;
  629. X
  630. X        case '"':
  631. X                /* a quote that is preceded with a backslash is ignored */
  632. X            if (do_quotes && (pos.col == 0 || linep[pos.col - 1] != '\\'))
  633. X                inquote = !inquote;
  634. X            break;
  635. X
  636. X        /*
  637. X         * Skip things in single quotes: 'x' or '\x'.
  638. X         * Be careful for single single quotes, eg jon's.
  639. X         * Things like '\233' or '\x3f' are not skipped, there is never a
  640. X         * brace in them.
  641. X         */
  642. X        case '\'':
  643. X            if (idx)                        /* backward search */
  644. X            {
  645. X                if (pos.col > 1)
  646. X                {
  647. X                    if (linep[pos.col - 2] == '\'')
  648. X                        pos.col -= 2;
  649. X                    else if (linep[pos.col - 2] == '\\' && pos.col > 2 && linep[pos.col - 3] == '\'')
  650. X                        pos.col -= 3;
  651. X                }
  652. X            }
  653. X            else if (linep[pos.col + 1])    /* forward search */
  654. X            {
  655. X                if (linep[pos.col + 1] == '\\' && linep[pos.col + 2] && linep[pos.col + 3] == '\'')
  656. X                    pos.col += 3;
  657. X                else if (linep[pos.col + 2] == '\'')
  658. X                    pos.col += 2;
  659. X            }
  660. X            break;
  661. X
  662. X        default:
  663. X            if (!inquote)      /* only check for match outside of quotes */
  664. X            {
  665. X                if (c == initc)
  666. X                    count++;
  667. X                else if (c == findc)
  668. X                {
  669. X                    if (count == 0)
  670. X                        return &pos;
  671. X                    count--;
  672. X                }
  673. X            }
  674. X        }
  675. X    }
  676. X    return (FPOS *) NULL;       /* never found it */
  677. X}
  678. X
  679. X/*
  680. X * findfunc(dir, what) - Find the next line starting with 'what' in direction 'dir'
  681. X *
  682. X * Return TRUE if a line was found.
  683. X */
  684. X    int
  685. Xfindfunc(dir, what, count)
  686. X    int         dir;
  687. X    int            what;
  688. X    long        count;
  689. X{
  690. X    linenr_t    curr;
  691. X
  692. X    curr = Curpos.lnum;
  693. X
  694. X    for (;;)
  695. X    {
  696. X        if (dir == FORWARD)
  697. X        {
  698. X                if (curr++ == line_count)
  699. X                        break;
  700. X        }
  701. X        else
  702. X        {
  703. X                if (curr-- == 1)
  704. X                        break;
  705. X        }
  706. X
  707. X        if (*nr2ptr(curr) == what)
  708. X        {
  709. X            if (--count > 0)
  710. X                continue;
  711. X            setpcmark();
  712. X            Curpos.lnum = curr;
  713. X            Curpos.col = 0;
  714. X            return TRUE;
  715. X        }
  716. X    }
  717. X
  718. X    return FALSE;
  719. X}
  720. X
  721. X/*
  722. X * findsent(dir, count) - Find the start of the next sentence in direction 'dir'
  723. X * Sentences are supposed to end in ".", "!" or "?" followed by white space or
  724. X * a line break. Also stop at an empty line.
  725. X * Return TRUE if the next sentence was found.
  726. X */
  727. X    int
  728. Xfindsent(dir, count)
  729. X        int     dir;
  730. X        long    count;
  731. X{
  732. X    FPOS            pos, tpos;
  733. X    register int    c;
  734. X    int             (*func) __PARMS((FPOS *));
  735. X    int             startlnum;
  736. X    int                noskip = FALSE;            /* do not skip blanks */
  737. X
  738. X    pos = Curpos;
  739. X    if (dir == FORWARD)
  740. X        func = incl;
  741. X    else
  742. X        func = decl;
  743. X
  744. X    while (count--)
  745. X    {
  746. X        /* if on an empty line, skip upto a non-empty line */
  747. X        if (gchar(&pos) == NUL)
  748. X        {
  749. X            do
  750. X                if ((*func)(&pos) == -1)
  751. X                    break;
  752. X            while (gchar(&pos) == NUL);
  753. X            if (dir == FORWARD)
  754. X                goto found;
  755. X        }
  756. X        /* if on the start of a paragraph or a section and searching
  757. X         * forward, go to the next line */
  758. X        else if (dir == FORWARD && pos.col == 0 && startPS(pos.lnum, NUL))
  759. X        {
  760. X            if (pos.lnum == line_count)
  761. X                return FALSE;
  762. X            ++pos.lnum;
  763. X            goto found;
  764. X        }
  765. X        else if (dir == BACKWARD)
  766. X            decl(&pos);
  767. X
  768. X        /* go back to the previous non-blank char */
  769. X        while ((c = gchar(&pos)) == ' ' || c == '\t' ||
  770. X                    (dir == BACKWARD && strchr(".!?)]\"'", c) != NULL && c != NUL))
  771. X            if (decl(&pos) == -1)
  772. X                break;
  773. X
  774. X        /* remember the line where the search started */
  775. X        startlnum = pos.lnum;
  776. X
  777. X        for (;;)                /* find end of sentence */
  778. X        {
  779. X            if ((c = gchar(&pos)) == NUL ||
  780. X                            (pos.col == 0 && startPS(pos.lnum, NUL)))
  781. X            {
  782. X                if (dir == BACKWARD && pos.lnum != startlnum)
  783. X                    ++pos.lnum;
  784. X                break;
  785. X            }
  786. X            if (c == '.' || c == '!' || c == '?')
  787. X            {
  788. X                tpos = pos;
  789. X                do
  790. X                    if ((c = inc(&tpos)) == -1)
  791. X                        break;
  792. X                while (strchr(")}\"'", c = gchar(&tpos)) != NULL && c != NUL);
  793. X                if (c == -1  || c == ' ' || c == '\t' || c == NUL)
  794. X                {
  795. X                    pos = tpos;
  796. X                    if (gchar(&pos) == NUL) /* skip NUL at EOL */
  797. X                        inc(&pos);
  798. X                    break;
  799. X                }
  800. X            }
  801. X            if ((*func)(&pos) == -1)
  802. X            {
  803. X                if (count)
  804. X                    return FALSE;
  805. X                noskip = TRUE;
  806. X                break;
  807. X            }
  808. X        }
  809. Xfound:
  810. X            /* skip white space */
  811. X        while (!noskip && ((c = gchar(&pos)) == ' ' || c == '\t'))
  812. X            if (incl(&pos) == -1)
  813. X                break;
  814. X    }
  815. X
  816. X    Curpos = pos;
  817. X    setpcmark();
  818. X    return TRUE;
  819. X}
  820. X
  821. X/*
  822. X * findpar(dir, count, what) - Find the next paragraph in direction 'dir'
  823. X * Paragraphs are currently supposed to be separated by empty lines.
  824. X * Return TRUE if the next paragraph was found.
  825. X * If 'what' is '{' or '}' we go to the next section.
  826. X */
  827. X    int
  828. Xfindpar(dir, count, what)
  829. X    register int    dir;
  830. X    long            count;
  831. X    int             what;
  832. X{
  833. X    register linenr_t    curr;
  834. X    int                    did_skip;        /* TRUE after separating lines have
  835. X                                                been skipped */
  836. X    int                    first;            /* TRUE on first line */
  837. X
  838. X    curr = Curpos.lnum;
  839. X
  840. X    while (count--)
  841. X    {
  842. X        did_skip = FALSE;
  843. X        for (first = TRUE; ; first = FALSE)
  844. X        {
  845. X                if (*nr2ptr(curr) != NUL)
  846. X                    did_skip = TRUE;
  847. X
  848. X                if (!first && did_skip && startPS(curr, what))
  849. X                    break;
  850. X
  851. X                if ((curr += dir) < 1 || curr > line_count)
  852. X                {
  853. X                        if (count)
  854. X                                return FALSE;
  855. X                        curr -= dir;
  856. X                        break;
  857. X                }
  858. X        }
  859. X    }
  860. X    setpcmark();
  861. X    Curpos.lnum = curr;
  862. X    if (curr == line_count)
  863. X    {
  864. X        if ((Curpos.col = strlen(nr2ptr(curr))) != 0)
  865. X            --Curpos.col;
  866. X        mincl = TRUE;
  867. X    }
  868. X    else
  869. X        Curpos.col = 0;
  870. X    return TRUE;
  871. X}
  872. X
  873. X/*
  874. X * check if the string 's' is a nroff macro that is in option 'opt'
  875. X */
  876. X    static int
  877. Xinmacro(opt, s)
  878. X        char *opt;
  879. X        register char *s;
  880. X{
  881. X        register char *macro;
  882. X
  883. X        for (macro = opt; macro[0]; ++macro)
  884. X        {
  885. X                if (macro[0] == s[0] && (((s[1] == NUL || s[1] == ' ')
  886. X                        && (macro[1] == NUL || macro[1] == ' ')) || macro[1] == s[1]))
  887. X                        break;
  888. X                ++macro;
  889. X                if (macro[0] == NUL)
  890. X                        break;
  891. X        }
  892. X        return (macro[0] != NUL);
  893. X}
  894. X
  895. X/*
  896. X * startPS: return TRUE if line 'lnum' is the start of a section or paragraph.
  897. X * If 'para' is '{' or '}' only check for sections.
  898. X */
  899. X    int
  900. XstartPS(lnum, para)
  901. X    linenr_t    lnum;
  902. X    int         para;
  903. X{
  904. X    register char *s;
  905. X
  906. X    s = nr2ptr(lnum);
  907. X    if (*s == para || *s == '\f')
  908. X        return TRUE;
  909. X    if (*s == '.' && (inmacro(p_sections, s + 1) || (!para && inmacro(p_para, s + 1))))
  910. X        return TRUE;
  911. X    return FALSE;
  912. X}
  913. X
  914. X/*
  915. X * The following routines do the word searches performed by the 'w', 'W',
  916. X * 'b', 'B', 'e', and 'E' commands.
  917. X */
  918. X
  919. X/*
  920. X * To perform these searches, characters are placed into one of three
  921. X * classes, and transitions between classes determine word boundaries.
  922. X *
  923. X * The classes are:
  924. X *
  925. X * 0 - white space
  926. X * 1 - letters, digits and underscore
  927. X * 2 - everything else
  928. X */
  929. X
  930. Xstatic int        stype;            /* type of the word motion being performed */
  931. X
  932. X/*
  933. X * cls() - returns the class of character at Curpos
  934. X *
  935. X * The 'type' of the current search modifies the classes of characters if a 'W',
  936. X * 'B', or 'E' motion is being done. In this case, chars. from class 2 are
  937. X * reported as class 1 since only white space boundaries are of interest.
  938. X */
  939. X    static int
  940. Xcls()
  941. X{
  942. X    register int c;
  943. X
  944. X    c = gcharCurpos();
  945. X    if (c == ' ' || c == '\t' || c == NUL)
  946. X        return 0;
  947. X
  948. X    if (isidchar(c))
  949. X        return 1;
  950. X
  951. X    /*
  952. X     * If stype is non-zero, report these as class 1.
  953. X     */
  954. X    return (stype == 0) ? 2 : 1;
  955. X}
  956. X
  957. X
  958. X/*
  959. X * fwd_word(count, type, eol) - move forward one word
  960. X *
  961. X * Returns TRUE if the cursor was already at the end of the file.
  962. X * If eol is TRUE, last word stops at end of line (for operators).
  963. X */
  964. X    int
  965. Xfwd_word(count, type, eol)
  966. X    long        count;
  967. X    int         type;
  968. X    int            eol;
  969. X{
  970. X    int         sclass;     /* starting class */
  971. X    int            i;
  972. X
  973. X    stype = type;
  974. X    while (--count >= 0)
  975. X    {
  976. X        sclass = cls();
  977. X
  978. X        /*
  979. X         * We always move at least one character.
  980. X         */
  981. X        i = incCurpos();
  982. X        if (i == -1)
  983. X            return TRUE;
  984. X        if (i == 1 && eol && count == 0)    /* started at last char in line */
  985. X            return FALSE;
  986. X
  987. X        if (sclass != 0)
  988. X            while (cls() == sclass)
  989. X            {
  990. X                i = incCurpos();
  991. X                if (i == -1 || (i == 1 && eol && count == 0))
  992. X                    return FALSE;
  993. X            }
  994. X
  995. X        /*
  996. X         * go to next non-white
  997. X         */
  998. X        while (cls() == 0)
  999. X        {
  1000. X            /*
  1001. X             * We'll stop if we land on a blank line
  1002. X             */
  1003. X            if (Curpos.col == 0 && *nr2ptr(Curpos.lnum) == NUL)
  1004. X                break;
  1005. X
  1006. X            i = incCurpos();
  1007. X            if (i == -1 || (i == 1 && eol && count == 0))
  1008. X                return FALSE;
  1009. X        }
  1010. X    }
  1011. X    return FALSE;
  1012. X}
  1013. X
  1014. X/*
  1015. X * bck_word(count, type) - move backward 'count' words
  1016. X *
  1017. X * Returns TRUE if top of the file was reached.
  1018. X */
  1019. X    int
  1020. Xbck_word(count, type)
  1021. X    long        count;
  1022. X    int         type;
  1023. X{
  1024. X    int         sclass;     /* starting class */
  1025. X
  1026. X    stype = type;
  1027. X    while (--count >= 0)
  1028. X    {
  1029. X        sclass = cls();
  1030. X
  1031. X        if (decCurpos() == -1)        /* started at start of file */
  1032. X            return TRUE;
  1033. X
  1034. X        if (cls() != sclass || sclass == 0)
  1035. X        {
  1036. X            /*
  1037. X             * We were at the start of a word. Go back to the end of the prior
  1038. X             * word.
  1039. X             */
  1040. X            while (cls() == 0)  /* skip any white space */
  1041. X            {
  1042. X                /*
  1043. X                 * We'll stop if we land on a blank line
  1044. X                 */
  1045. X                if (Curpos.col == 0 && *nr2ptr(Curpos.lnum) == NUL)
  1046. X                    goto finished;
  1047. X
  1048. X                if (decCurpos() == -1)        /* hit start of file, stop here */
  1049. X                    return FALSE;
  1050. X            }
  1051. X            sclass = cls();
  1052. X        }
  1053. X
  1054. X        /*
  1055. X         * Move backward to start of this word.
  1056. X         */
  1057. X        if (skip_chars(sclass, BACKWARD))
  1058. X                return FALSE;
  1059. X
  1060. X        incCurpos();                    /* overshot - forward one */
  1061. Xfinished:
  1062. X        ;
  1063. X    }
  1064. X    return FALSE;
  1065. X}
  1066. X
  1067. X/*
  1068. X * end_word(count, type, stop) - move to the end of the word
  1069. X *
  1070. X * There is an apparent bug in the 'e' motion of the real vi. At least on the
  1071. X * System V Release 3 version for the 80386. Unlike 'b' and 'w', the 'e'
  1072. X * motion crosses blank lines. When the real vi crosses a blank line in an
  1073. X * 'e' motion, the cursor is placed on the FIRST character of the next
  1074. X * non-blank line. The 'E' command, however, works correctly. Since this
  1075. X * appears to be a bug, I have not duplicated it here.
  1076. X *
  1077. X * Returns TRUE if end of the file was reached.
  1078. X *
  1079. X * If stop is TRUE and we are already on the end of a word, move one less.
  1080. X */
  1081. X    int
  1082. Xend_word(count, type, stop)
  1083. X    long        count;
  1084. X    int         type;
  1085. X    int            stop;
  1086. X{
  1087. X    int         sclass;     /* starting class */
  1088. X
  1089. X    stype = type;
  1090. X    while (--count >= 0)
  1091. X    {
  1092. X        sclass = cls();
  1093. X        if (incCurpos() == -1)
  1094. X            return TRUE;
  1095. X
  1096. X        /*
  1097. X         * If we're in the middle of a word, we just have to move to the end of it.
  1098. X         */
  1099. X        if (cls() == sclass && sclass != 0)
  1100. X        {
  1101. X            /*
  1102. X             * Move forward to end of the current word
  1103. X             */
  1104. X            if (skip_chars(sclass, FORWARD))
  1105. X                    return TRUE;
  1106. X        }
  1107. X        else if (!stop || sclass == 0)
  1108. X        {
  1109. X            /*
  1110. X             * We were at the end of a word. Go to the end of the next word.
  1111. X             */
  1112. X
  1113. X            if (skip_chars(0, FORWARD))     /* skip any white space */
  1114. X                return TRUE;
  1115. X
  1116. X            /*
  1117. X             * Move forward to the end of this word.
  1118. X             */
  1119. X            if (skip_chars(cls(), FORWARD))
  1120. X                return TRUE;
  1121. X        }
  1122. X        decCurpos();                    /* overshot - backward one */
  1123. X        stop = FALSE;                    /* we move only one word less */
  1124. X    }
  1125. X    return FALSE;
  1126. X}
  1127. X
  1128. X    int
  1129. Xskip_chars(class, dir)
  1130. X    int class;
  1131. X    int dir;
  1132. X{
  1133. X        while (cls() == class)
  1134. X            if ((dir == FORWARD ? incCurpos() : decCurpos()) == -1)
  1135. X                return TRUE;
  1136. X        return FALSE;
  1137. X}
  1138. END_OF_FILE
  1139. if test 24021 -ne `wc -c <'vim/src/search.c'`; then
  1140.     echo shar: \"'vim/src/search.c'\" unpacked with wrong size!
  1141. fi
  1142. chmod +x 'vim/src/search.c'
  1143. # end of 'vim/src/search.c'
  1144. fi
  1145. if test -f 'vim/tutor/tutor' -a "${1}" != "-c" ; then 
  1146.   echo shar: Will not clobber existing file \"'vim/tutor/tutor'\"
  1147. else
  1148. echo shar: Extracting \"'vim/tutor/tutor'\" \(28799 characters\)
  1149. sed "s/^X//" >'vim/tutor/tutor' <<'END_OF_FILE'
  1150. X*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
  1151. X*    W e l c o m e   t o   V I   T u t o r    -    V e r s i o n   1 . 2      *
  1152. X*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
  1153. X                             **************
  1154. X                             * Lesson 1.0 *
  1155. X                             **************
  1156. X
  1157. X     Vim is a very powerful editor that has many commands, too many to 
  1158. X     explain in a tutor such as this.  This tutor is designed to describe
  1159. X     enough of the commands that you will be able to easily use Vim as
  1160. X     an all-purpose editor. 
  1161. X
  1162. X     The approximate time required to complete the tutor is 25-30 minutes, 
  1163. X     depending upon how much time is spent with experimentation.
  1164. X
  1165. X     It is important to remember that this tutor is set up to teach by
  1166. X     use.  That means that the student needs to execute the commands to 
  1167. X     learn them properly.  
  1168. X
  1169. X     Now, make sure that your Shift-Lock key is NOT depressed and press
  1170. X     the   j   key enough times to move the cursor so that Lesson 1.1 
  1171. X     completely fills the screen.
  1172. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1173. X                             **************
  1174. X                             * Lesson 1.1 *
  1175. X                             **************
  1176. X                 =====>>>>> MOVING THE CURSOR <<<<<=====
  1177. X
  1178. X   ** To move the cursor, press the h,j,k,l keys as indicated. ** 
  1179. X                                   ^
  1180. X                                   k
  1181. X                             < h       l >
  1182. X                                   j
  1183. X                                   v
  1184. X  1. Move the cursor around the screen until you are comfortable.
  1185. X
  1186. X  2. Hold down the down key (j) until it repeats.
  1187. X---> Now you know how to move to the next lesson.
  1188. X
  1189. X  3. Using the down key, move to Lesson 1.2.
  1190. X
  1191. XNote: If you are ever unsure about something you typed, press <ESC> to place
  1192. X      you in Command Mode.  Then retype the command you wanted.
  1193. X
  1194. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1195. X                             **************
  1196. X                             * Lesson 1.2 *
  1197. X                             **************
  1198. X              =====>>>>> ENTERING AND EXITING VIM <<<<<=====
  1199. X
  1200. X  !! NOTE: Before executing any of the steps below, read this entire lesson!!
  1201. X
  1202. X  1. Press the <ESC> key (to make sure you are in Command Mode).
  1203. X
  1204. X  2. Type      :q! <RETURN>.
  1205. X
  1206. X---> This exits the editor WITHOUT saving any changes you have made.
  1207. X     If you want to save the changes and exit type        :wq  <RETURN>
  1208. X
  1209. X  3. When you see the shell prompt (%) type:    vim tutor <RETURN>.
  1210. X
  1211. X---> 'vim' means enter the vim editor, 'tutor' is the file you wish to edit.
  1212. X
  1213. X  4. If you have these steps memorized and are confident, execute steps
  1214. X     1 through 3 to exit and re-enter the editor.  Then cursor down to 
  1215. X     Lesson 1.3.
  1216. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1217. X                             **************
  1218. X                             * Lesson 1.3 *
  1219. X                             **************
  1220. X              =====>>>>> TEXT EDITING - DELETION <<<<<=====
  1221. X
  1222. X** While in Command Mode press  x  to delete the character under the cursor. **
  1223. X
  1224. X  1. Move the cursor to the line below marked --->.
  1225. X
  1226. X  2. To fix the errors, move the cursor until it is on top of the
  1227. X     character to be deleted.
  1228. X
  1229. X  3. Press the  x  key to delete the unwanted character.
  1230. X
  1231. X  4. Repeat steps 2 through 4 until the sentence is correct.
  1232. X
  1233. X---> The ccow jumpedd ovverr thhe mooon.
  1234. X
  1235. X  5. Now that the line is correct, go on to Lesson 1.4.
  1236. X
  1237. XNOTE: As you go through this tutor, do not try to memorize, learn by usage.
  1238. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1239. X                             **************
  1240. X                             * Lesson 1.4 *
  1241. X                             **************
  1242. X             =====>>>>> TEXT EDITING - INSERTION <<<<<=====
  1243. X
  1244. X         ** While in Command Mode press  i  to insert text. **
  1245. X
  1246. X  1. Move the cursor to the first line below marked --->.
  1247. X
  1248. X  2. To make the first line the same as the second, move the cursor on top 
  1249. X     of the first character AFTER where the text is to be inserted.
  1250. X
  1251. X  3. Press  i  and type in the necessary additions.
  1252. X
  1253. X  4. As each error is fixed press <ESC> to return to Command Mode.
  1254. X     Repeat steps 2 through 4 to correct the sentence.
  1255. X
  1256. X---> There is text misng this .
  1257. X---> There is some text missing from this line.
  1258. X
  1259. X  5. When you are comfortable inserting text move to the summary below.
  1260. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1261. X                          ********************
  1262. X                          * LESSON 1 SUMMARY *
  1263. X                          ********************
  1264. X
  1265. X  1. The cursor is moved using either the arrow keys or the h,j,k,l keys.
  1266. X         h (left)       j (down)       k (up)       l (right)
  1267. X
  1268. X  2. To enter Vim (from the % prompt) type:      % vim FILENAME <RETURN>
  1269. X
  1270. X  3. To exit Vim type:     <ESC>   :q!   <RETURN>
  1271. X             OR type:      <ESC>   :wq   <RETURN>  to save the changes.
  1272. X
  1273. X  4. To delete a character under the cursor in Command Mode type:  x
  1274. X
  1275. X  5. To insert text at the cursor while in Command Mode type:
  1276. X         i     type in text     <ESC>
  1277. X
  1278. XNOTE: Pressing <ESC> will place you in Command Mode or will cancel
  1279. X      an unwanted and partially completed command.
  1280. X
  1281. XNow continue with Lesson 2.
  1282. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1283. X                             **************
  1284. X                             * Lesson 2.1 *
  1285. X                             **************
  1286. X                =====>>>>> DELETION COMMANDS <<<<<=====
  1287. X
  1288. X            ** Type  dw  to delete to the end of a word. **
  1289. X
  1290. X  1. Press  <ESC>  to make sure you are in Command Mode.
  1291. X
  1292. X  2. Move the cursor to the line below marked --->.
  1293. X
  1294. X  3. Move the cursor to the beginning of a word that needs to be deleted.
  1295. X  
  1296. X  4. Type   dw   to make the word disappear.
  1297. X
  1298. X  NOTE: The letters dw will appear on the last line of the screen as you type
  1299. X      them. If you typed something wrong, press  <ESC>  and start over.
  1300. X
  1301. X---> There are a some words fun that don't belong paper in this sentence.
  1302. X
  1303. X  5. Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2.
  1304. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1305. X                 **************
  1306. X                 * Lesson 2.2 *
  1307. X                 **************
  1308. X              =====>>>>> MORE DELETION COMMANDS <<<<<=====
  1309. X
  1310. X           ** Type  d$  to delete to the end of the line. **
  1311. X
  1312. X  1. Press  <ESC>  to make sure you are in Command Mode.
  1313. X
  1314. X  2. Move the cursor to the line below marked --->.
  1315. X
  1316. X  3. Move the cursor to the end of the correct line (AFTER the first . ).
  1317. X
  1318. X  4. Type    d$    to delete to the end of the line.
  1319. X
  1320. X---> Somebody typed the end of this line twice. end of this line twice.
  1321. X
  1322. X
  1323. X  5. Move on to Lesson 2.3 to understand what is happening.
  1324. X
  1325. X
  1326. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1327. X                 **************
  1328. X                 * Lesson 2.3 *
  1329. X                 **************
  1330. X             =====>>>>> ON COMMANDS AND OBJECTS <<<<<=====
  1331. X
  1332. X  The format for the  d  delete command is as follows:
  1333. X
  1334. X         [number]   d   object      OR       d   [number]   object
  1335. X  Where: 
  1336. X    number - is how many times to execute the command (optional, default=1).
  1337. X    d - is the command to delete.
  1338. X    object - is what the command will operate on (listed below).
  1339. X
  1340. X  A short list of objects:
  1341. X    w - from the cursor to the end of the word, including the space.
  1342. X    e - from the cursor to the end of the word, NOT including the space.
  1343. X    $ - from the cursor to the end of the line.
  1344. X    
  1345. XNOTE:  For the adventurous, pressing just the object while in Command Mode
  1346. X       without a command will move the cursor as specified in the object list.
  1347. X
  1348. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1349. X                             **************
  1350. X                             * Lesson 2.4 *
  1351. X                             **************
  1352. X        =====>>>>> AN EXCEPTION TO  'COMMAND-OBJECT' <<<<<=====
  1353. X
  1354. X               ** Type   dd   to delete a whole line. **
  1355. X
  1356. X  Due to the frequency of whole line deletion, the designers of Vim decided
  1357. X  it would be easier to simply type two d's in a row to delete a line.
  1358. X
  1359. X  1. Move the cursor to the second line in the phrase below. 
  1360. X
  1361. X  2. Type  dd  to delete the line.
  1362. X
  1363. X  3. Now move to the fourth line.
  1364. X
  1365. X  4. Type   2dd   (remember  number-command-object) to delete the two lines.
  1366. X
  1367. X      1)  Roses are red,
  1368. X      2)  Mud is fun,
  1369. X      3)  Violets are blue,
  1370. X      4)  I have a car,
  1371. X      5)  Clocks tell time,
  1372. X      6)  Sugar is sweet
  1373. X      7)  And so are you.
  1374. X
  1375. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1376. X                             **************
  1377. X                             * Lesson 2.5 *
  1378. X                             **************
  1379. X                 =====>>>>> THE UNDO COMMAND <<<<<=====
  1380. X
  1381. X   ** Press  u  to undo the last commands,   U   to fix a whole line. **
  1382. X
  1383. X  1. Move the cursor to the line below marked ---> and place it on the
  1384. X     first error.
  1385. X  2. Type  x  to delete the first unwanted character.
  1386. X  3. Now type  u  to undo the last command executed.
  1387. X  4. This time fix all the errors on the line using the  x  command.
  1388. X  5. Now type a capital  U  to return the line to its original state.
  1389. X  6. Now type  u  a few times to undo the  U  and preceding commands.
  1390. X  7. Now type CTRL-R (keeping CTRL key pressed while hitting R) a few times
  1391. X     to redo the commands (undo the undo's).
  1392. X
  1393. X---> Fiix the errors oon thhis line and reeplace them witth undo.
  1394. X
  1395. X  8. These are very useful commands.  Now move on to the Lesson 2 Summary.
  1396. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1397. X                          ********************
  1398. X                          * LESSON 2 SUMMARY *
  1399. X                          ********************
  1400. X
  1401. X  1. To delete from the cursor to the end of a word type:    dw
  1402. X
  1403. X  2. To delete from the cursor to the end of a line type:    d$
  1404. X
  1405. X  3. To delete a whole line type:    dd
  1406. X
  1407. X  4. The format for a command in command mode is:
  1408. X
  1409. X       [number]   command   object     OR     command   [number]   object
  1410. X     where:
  1411. X       number - is how many times to repeat the command
  1412. X       command - is what to do, such as  d  for delete
  1413. X       object - is what the command should act upon, such as  w (word),
  1414. X                $ (to the end of line), etc.
  1415. X
  1416. X  5. To undo previous actions, type:         u   (lowercase u)
  1417. X     To undo all the changes on a line type: U   (capital U)
  1418. X     To undo the undo's type:             CTRL-R
  1419. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1420. X                             **************
  1421. X                             * Lesson 3.1 *
  1422. X                             **************
  1423. X                 =====>>>>> THE PUT COMMAND <<<<<=====
  1424. X
  1425. X       ** Type  p  to put the last deletion after the cursor. **
  1426. X
  1427. X  1. Move the cursor to the first line in the set below.
  1428. X
  1429. X  2. Type  dd  to delete the line and store it in Vim's buffer.
  1430. X
  1431. X  3. Move the cursor to the line ABOVE where the deleted line should go.
  1432. X
  1433. X  4. While in Command Mode, type    p    to replace the line.
  1434. X
  1435. X  5. Repeat steps 2 through 4 to put all the lines in correct order.
  1436. X
  1437. X     d) Can you learn too?
  1438. X     b) Violets are blue,
  1439. X     c) Intelligence is learned,
  1440. X     a) Roses are red,
  1441. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1442. X                             **************
  1443. X                             * Lesson 3.2 *
  1444. X                             **************
  1445. X               =====>>>>> THE REPLACE COMMAND <<<<<=====
  1446. X
  1447. X  ** Type  r  and a character to replace the character under the cursor. **
  1448. X
  1449. X  1. Move the cursor to the first line below marked --->.
  1450. X
  1451. X  2. Move the cursor so that it is on top of the first error.
  1452. X
  1453. X  3. Type   r   and then the character which should replace the error.
  1454. X
  1455. X  4. Repeat steps 2 and 3 until the first line is correct.
  1456. X
  1457. X--->  Whan this lime was tuoed in, someone presswd some wrojg keys!
  1458. X--->  When this line was typed in, someone pressed some wrong keys!
  1459. X
  1460. X  5. Now move on to Lesson 3.2.
  1461. X
  1462. XNOTE: Remember that you should be learning by use, not memorization.
  1463. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1464. X                             **************
  1465. X                             * Lesson 3.3 *
  1466. X                             **************
  1467. X                =====>>>>> THE CHANGE COMMAND <<<<<=====
  1468. X
  1469. X           ** To change part or all of a word, type  cw . **
  1470. X
  1471. X  1. Move the cursor to the first line below marked --->.
  1472. X
  1473. X  2. Place the cursor on the u in lubw.  
  1474. X
  1475. X  3. Type  cw  and the correct word (in this case, type  'ine'.)
  1476. X
  1477. X  4. Press <ESC> and move to the next error (the first character to be changed.)
  1478. X
  1479. X  5. Repeat steps 3 and 4 until the first sentence is the same as the second.
  1480. X
  1481. X---> This lubw has a few wptfd that mrrf changing usf the change command.
  1482. X---> This line has a few words that need changing using the change command. 
  1483. X
  1484. XNotice that  cw  not only replaces the word, but also places you in insert.
  1485. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1486. X                             **************
  1487. X                             * Lesson 3.4 *
  1488. X                             **************
  1489. X               =====>>>>> MORE CHANGES USING c <<<<<=====
  1490. X
  1491. X     ** The change command is used with the same objects as delete. **
  1492. X
  1493. X  1. The change command works in the same way as delete.  The format is:
  1494. X
  1495. X       [number]   c   object       OR       c   [number]   object
  1496. X
  1497. X  2. The objects are also the same, such as   w (word), $ (end of line), etc.
  1498. X
  1499. X  3. Move to the first line below marked --->.
  1500. X
  1501. X  4. Move the cursor to the first error.
  1502. X  5. Type  c$  to make the rest of the line like the second and press <ESC>.
  1503. X
  1504. X---> The end of this line needs some help to make it like the second. 
  1505. X---> The end of this line needs to be corrected using the  c$  command.
  1506. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1507. X                          ********************
  1508. X                          * LESSON 3 SUMMARY *
  1509. X                          ********************
  1510. X
  1511. X  1. To replace text that has already been deleted, type   p .  This Puts the
  1512. X     deleted text AFTER the cursor (if a line was deleted it will go on the
  1513. X     line below the cursor).
  1514. X
  1515. X  2. To replace the character under the cursor, type   r   and then the 
  1516. X     character which will replace the original.
  1517. X
  1518. X  3. The change command allows you to change the specified object from the
  1519. X     cursor to the end of the object.  eg. Type  cw  to change from the
  1520. X     cursor to the end of the word, c$  to change to the end of a line.
  1521. X
  1522. X  4. The format for change is:
  1523. X    
  1524. X         [number]   c   object        OR        c   [number]   object
  1525. X
  1526. XNow go on to the next lesson.
  1527. X
  1528. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1529. X                             **************
  1530. X                             * Lesson 4.1 *
  1531. X                             **************
  1532. X             =====>>>>> LOCATION AND FILE STATUS <<<<<=====
  1533. X
  1534. X  ** Type CTRL-g to show your location in the file and the file status.   
  1535. X     Type SHIFT-G to move to a line in the file. **
  1536. X
  1537. X  Note: Read this entire lesson before executing any of the steps!!
  1538. X
  1539. X  1. Hold down the Ctrl key and press  g .  A status line will appear at the
  1540. X     bottom of the page with the filename and the line you are on.  Remember
  1541. X     the line number for Step 3.
  1542. X
  1543. X  2. Press shift-G to move you to the bottom of the file. 
  1544. X
  1545. X  3. Type in the number of the line you were on and then shift-G.  This will 
  1546. X     return you to the line you were on when you first pressed Ctrl-g.
  1547. X     (When you type in the numbers, they will NOT be displayed on the screen.)
  1548. X
  1549. X  4. If you feel confident to do this, execute steps 1 through 3.
  1550. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1551. X                             **************
  1552. X                             * Lesson 4.2 *
  1553. X                             **************
  1554. X                =====>>>>> THE SEARCH COMMAND <<<<<=====
  1555. X
  1556. X     ** Type  /  followed by a phrase to search for the phrase. **
  1557. X
  1558. X  1. In command mode type the  /  character.  Notice that it and the cursor
  1559. X     appear at the bottom of the screen as with the  :  command.
  1560. X
  1561. X  2. Now type 'errroor' <RETURN>.  This is the word you want to search for.
  1562. X
  1563. X  3. To search for the same phrase again, simply type  n .
  1564. X     To search for the same phrase in the opposite direction, type  Shift-N .
  1565. X
  1566. X  4. If you want to search for a phrase in the backwards direction, use the
  1567. X     command  ?  instead of /.
  1568. X
  1569. X---> When the search reaches the end of the file it will continue at the start.
  1570. X
  1571. X  "errroor" is not the way to spell error;  errroor is an error.
  1572. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1573. X                             **************
  1574. X                             * Lesson 4.3 *
  1575. X                             **************
  1576. X            =====>>>>> MATCHING PARENTHESES SEARCH <<<<<=====
  1577. X
  1578. X              ** Type  %  to find a matching ),], or } . **
  1579. X
  1580. X  1. Place the cursor on any (, [, or { in the line below marked --->. 
  1581. X
  1582. X  2. Now type the  %  character.
  1583. X
  1584. X  3. The cursor should be on the matching parenthesis or bracket.
  1585. X
  1586. X  4. Type  %  to move the cursor back to the first bracket (by matching).
  1587. X
  1588. X---> This ( is a test line with ('s, ['s ] and {'s } in it. ))
  1589. X
  1590. XNote: This is very useful in debugging a program with unmatched parentheses!
  1591. X
  1592. X
  1593. X
  1594. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1595. X                             **************
  1596. X                             * Lesson 4.4 *
  1597. X                             **************
  1598. X              =====>>>>> A WAY TO CHANGE ERRORS <<<<<=====
  1599. X
  1600. X        ** Type  :s/old/new/g  to substitute 'new' for 'old'. **
  1601. X
  1602. X  1. Move the cursor to the line below marked --->.
  1603. X
  1604. X  2. Type  :s/thee/the <RETURN> .  Note that this command only changes the 
  1605. X     first occurrence on the line.
  1606. X
  1607. X  3. Now type    :s/thee/the/g     meaning substitute globally on the line.
  1608. X     This changes all occurrences on the line.
  1609. X
  1610. X---> thee best time to see thee flowers is in thee spring.
  1611. X
  1612. X  4. To change every occurrence of a character string between two lines,
  1613. X     type   :#,#s/old/new/g    where #,# are the numbers of the two lines.
  1614. X     Type   :%s/old/new/g    to change every occurrence in the whole file.
  1615. X
  1616. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1617. X                          ********************
  1618. X                          * LESSON 4 SUMMARY *
  1619. X                          ********************
  1620. X
  1621. X  1. Ctrl-g  displays your location in the file and the file status.
  1622. X     Shift-G  moves to the end of the file.  A line number followed 
  1623. X     by  Shift-G  moves to that line number.
  1624. X
  1625. X  2. Typing  /  followed by a phrase searches FORWARD for the phrase.
  1626. X     Typing  ?  followed by a phrase searches BACKWARD for the phrase.
  1627. X     After a search type  n  to find the next occurrence in the same direction
  1628. X     or  Shift-N  to search in the opposite direction.
  1629. X
  1630. X  3. Typing  %  while the cursor is on a  (,),[,],{, or }  locates its 
  1631. X     matching pair.
  1632. X
  1633. X  4. To substitute new for the first old on a line type    :s/old/new
  1634. X     To substitute new for all 'old's on a line type       :s/old/new/g
  1635. X     To substitute phrases between two line #'s type       :#,#s/old/new/g
  1636. X     To substitute all occurrences in the file type        :%s/old/new/g
  1637. X     To ask for confirmation each time add 'c'             :%s/old/new/gc
  1638. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1639. X                             **************
  1640. X                             * Lesson 5.1 *
  1641. X                             **************
  1642. X          =====>>>>> HOW TO EXECUTE AN AMIGA COMMAND <<<<<=====
  1643. X
  1644. X   ** Type  :!  followed by an Amiga command to execute that command. **
  1645. X
  1646. X  1. Type the familiar command  :  to set the cursor at the bottom of the
  1647. X     screen.  This allows you to enter a command.
  1648. X
  1649. X  2. Now type the  !  (exclamation point) character.  This allows you to 
  1650. X     execute an Amiga shell command.
  1651. X
  1652. X  3. As an example type   ls   following the !.  This will show you a listing
  1653. X     of your directory, just as if you were at the  %  prompt.
  1654. X
  1655. X---> Note:  It is possible to execute any shell command this way.
  1656. X
  1657. X
  1658. X
  1659. X
  1660. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1661. X                             **************
  1662. X                             * Lesson 5.2 *
  1663. X                             **************
  1664. X              =====>>>>> MORE ON WRITING FILES <<<<<=====
  1665. X
  1666. X     ** To save the changes made to the file, type  :w FILENAME. **
  1667. X
  1668. X  1. Type  :!dir  to get a listing of your directory.
  1669. X
  1670. X  2. Choose a filename that is not already in your area, such as TEST.
  1671. X
  1672. X  3. Now type:   :w TEST   (where TEST is the filename you chose.)
  1673. X
  1674. X  4. This saves the whole file  (Vim Tutor)  under the name TEST.
  1675. X     To verify this, type    :!dir   again to see your directory
  1676. X
  1677. X---> Note that if you were to exit Vim and enter again with the filename TEST,
  1678. X     the file would be an exact copy of the tutor when you saved it.
  1679. X
  1680. X  5. Now remove the file from your area by typing:     :!delete TEST
  1681. X
  1682. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1683. X                             **************
  1684. X                             * Lesson 5.3 *
  1685. X                             **************
  1686. X            =====>>>>> A SELECTIVE WRITE COMMAND <<<<<=====
  1687. X
  1688. X        ** To save part of the file, type   :#,# w FILENAME **
  1689. X
  1690. X  1. Once again, type    :!dir    to obtain a listing of your directory and
  1691. X     choose a suitable filename such as TEST.
  1692. X
  1693. X  2. Move the cursor to the top of this page and type  Ctrl-g  to find the 
  1694. X     number of that line.  REMEMBER THIS NUMBER!
  1695. X
  1696. X  3. Now move to the bottom of the page and type  Ctrl-g again.  REMEMBER THIS
  1697. X     LINE NUMBER ALSO!
  1698. X
  1699. X  4. To save ONLY a section to a file, type   :#,# w TEST   where #,# are
  1700. X     the two numbers you remembered (top,bottom) and TEST is your filename.
  1701. X
  1702. X  5. Again, see that the file is there with  :!dir  but DO NOT remove it.      
  1703. X
  1704. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1705. X                             **************
  1706. X                             * Lesson 5.4 *
  1707. X                             **************
  1708. X           =====>>>>> RETRIEVING AND MERGING FILES <<<<<=====
  1709. X
  1710. X       ** To insert the contents of a file, type   :r FILENAME **
  1711. X
  1712. X  1. Type   :!dir   to make sure your TEST filename is present from before.
  1713. X
  1714. X  2. Place the cursor at the top of this page.
  1715. X
  1716. XNOTE:  After executing Step 3 you will see Lesson 5.3.  Then move DOWN to
  1717. X       this lesson again.
  1718. X
  1719. X  3. Now retrieve your TEST file using the command   :r TEST   where TEST is 
  1720. X     the name of the file.  
  1721. X
  1722. XNOTE:  The file you retrieve is placed starting where the cursor is located.
  1723. X
  1724. X  4. To verify that a file was retrieved, cursor back and notice that there 
  1725. X     are now two copies of Lesson 5.3, the original and the file version. 
  1726. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1727. X                          ********************
  1728. X                          * LESSON 5 SUMMARY *
  1729. X                          ********************
  1730. X
  1731. X  1.  :!command  executes an Amiga system command.
  1732. X
  1733. X      Some useful examples are:
  1734. X          :!dir  -  shows a directory listing of your area.
  1735. X          :!delete FILENAME  -  removes file FILENAME from your area.
  1736. X
  1737. X  2.  :w FILENAME  writes the current Vim file to disk with name FILENAME.
  1738. X
  1739. X  3.  :#,# FILENAME  saves the lines # through # in file FILENAME.
  1740. X
  1741. X  4.  :r FILENAME  retrieves disk file FILENAME and inserts it into the
  1742. X      current file following the cursor position.
  1743. X
  1744. X
  1745. X
  1746. X
  1747. X
  1748. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1749. X                             **************
  1750. X                             * Lesson 6.1 *
  1751. X                             **************
  1752. X                 =====>>>>> THE OPEN COMMAND <<<<<=====
  1753. X
  1754. X ** Type  o  to open a line below the cursor and place you in insert mode. **
  1755. X
  1756. X  1. Move the cursor to the line below marked --->.
  1757. X
  1758. X  2. Type  o (lowercase) to open up a line BELOW the cursor and place you in
  1759. X     insert mode.
  1760. X
  1761. X  3. Now copy the line marked ---> and press <ESC> to exit insert mode.
  1762. X
  1763. X---> After typing  o  the cursor is placed on the open line in insert mode.
  1764. X
  1765. X  4. To open up a line ABOVE the cursor, simply type a capital  O , rather
  1766. X     than a lowercase  o.  Try this on the line below.
  1767. XOpen up a line above this by typing Shift-O while the cursor is on this line.
  1768. X
  1769. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1770. X                             **************
  1771. X                             * Lesson 6.2 *
  1772. X                             **************
  1773. X                =====>>>>> THE APPEND COMMAND <<<<<=====
  1774. X
  1775. X             ** Type  a  to insert text AFTER the cursor. **
  1776. X
  1777. X  1. Move the cursor to the end of the first line below marked ---> by 
  1778. X     typing  $  in Command mode.
  1779. X
  1780. X  2. Type an  a  (lowercase) to append text AFTER the character under the
  1781. X     cursor.  (Uppercase  A  appends to the end of the line.)
  1782. X
  1783. XNote: This avoids typing  i , the last character, the text to insert, <ESC>,
  1784. X      cursor-right, and finally, x , just to append to the end of a line!
  1785. X
  1786. X  3. Now complete the first line.  Note also that append is exactly the same
  1787. X     as insert mode, except for the location where text is inserted.
  1788. X
  1789. X---> This line will allow you to practice
  1790. X---> This line will allow you to practice appending text to the end of a line.
  1791. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1792. X                             **************
  1793. X                             * Lesson 6.3 *
  1794. X                             **************
  1795. X            =====>>>>> ANOTHER VERSION OF REPLACE <<<<<=====
  1796. X
  1797. X      ** Type a capital  R  to replace more than one character. **
  1798. X
  1799. X  1. Move the cursor to the first line below marked --->.
  1800. X
  1801. X  2. Place the cursor at the beginning of the first word that is different
  1802. X     from the second line marked ---> (the word 'last').
  1803. X
  1804. X  3. Now type  R  and replace the remainder of the text on the first line by
  1805. X     typing over the old text to make the first line the same as the second.
  1806. X
  1807. X---> To make the first line the same as the last on this page use the keys.
  1808. X---> To make the first line the same as the second, type R and the new text.
  1809. X
  1810. X  4. Note that when you press <ESC> to exit, any unaltered text remains.
  1811. X
  1812. X
  1813. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1814. X                             **************
  1815. X                             * Lesson 6.4 *
  1816. X                             **************
  1817. X            =====>>>>> SET ENVIRONMENT VARIABLE <<<<<=====
  1818. X
  1819. X      ** Change environment so a search or substitute ignores case **
  1820. X
  1821. X
  1822. X  1. Search for 'ignore' by entering: 
  1823. X     /ignore
  1824. X     Repeat several times by hitting the n key
  1825. X
  1826. X  2. Set the 'ic' (Ignore case) variable by typing: 
  1827. X     :set ic
  1828. X
  1829. X  3. Now search for 'ignore' again by entering: n
  1830. X     Repeat search several more times by hitting the n key
  1831. X
  1832. X
  1833. X
  1834. X
  1835. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1836. X                          ********************
  1837. X                          * LESSON 6 SUMMARY *
  1838. X                          ********************
  1839. X
  1840. X  1. Typing  o  opens a line BELOW the cursor and places the cursor on the open
  1841. X     line in insert mode.
  1842. X     Typing a capital  O  opens the line ABOVE the line the cursor is on.
  1843. X
  1844. X  2. Type an  a  to insert text AFTER the character the cursor is on.
  1845. X     Typing a capital  A  automatically appends text to the end of the line. 
  1846. X
  1847. X  3. Typing a capital  R  enters replace mode until  <ESC>  is pressed to exit.
  1848. X
  1849. X  4. Typing ":set xxx" sets the environment variable "xxx"
  1850. X
  1851. X
  1852. X
  1853. X
  1854. X
  1855. X
  1856. X
  1857. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1858. X
  1859. X  This concludes the Vim Tutor.  It was intended to give a brief overview of
  1860. X  the Vim editor, just enough to allow you to use the editor fairly easily.
  1861. X  It is far from complete as Vim has many many more commands.
  1862. X
  1863. X  For more information on Vim editor please refer to:
  1864. X
  1865. X    doc/reference.doc - a complete description of Vim
  1866. X    doc/index - a short summary of all commands
  1867. X    doc/difference.doc - summary of differences between vi and Vim
  1868. X
  1869. X  Or hit the HELP key!
  1870. X
  1871. X  This tutorial was written by Michael C. Pierce and Robert K. Ware,
  1872. X  Colorado School of Mines using ideas supplied by Charles Smith,
  1873. X  Colorado State University.
  1874. X  E-mail: bware@mines.colorado.edu.
  1875. X
  1876. X  Modified for Vim by Bram Moolenaar.
  1877. X
  1878. X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1879. END_OF_FILE
  1880. if test 28799 -ne `wc -c <'vim/tutor/tutor'`; then
  1881.     echo shar: \"'vim/tutor/tutor'\" unpacked with wrong size!
  1882. fi
  1883. chmod +x 'vim/tutor/tutor'
  1884. # end of 'vim/tutor/tutor'
  1885. fi
  1886. echo shar: End of archive 13 \(of 25\).
  1887. cp /dev/null ark13isdone
  1888. MISSING=""
  1889. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 ; do
  1890.     if test ! -f ark${I}isdone ; then
  1891.     MISSING="${MISSING} ${I}"
  1892.     fi
  1893. done
  1894. if test "${MISSING}" = "" ; then
  1895.     echo You have unpacked all 25 archives.
  1896.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1897. else
  1898.     echo You still need to unpack the following archives:
  1899.     echo "        " ${MISSING}
  1900. fi
  1901. ##  End of shell archive.
  1902. exit 0
  1903.  
  1904. ===============================================================================
  1905. Bram Moolenaar                             | DISCLAIMER:  This  note  does  not
  1906. Oce Nederland B.V., Research & Development | necessarily represent the position
  1907. p.o. box 101, 5900 MA  Venlo               | of  Oce-Nederland  B.V.  Therefore
  1908. The Netherlands        phone +31 77 594077 | no liability or responsibility for
  1909. UUCP: mool@oce.nl        fax +31 77 595473 | whatever will be accepted.
  1910.  
  1911. exit 0 # Just in case...
  1912.