home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.2.327 < prev    next >
Encoding:
Internet Message Format  |  2004-03-07  |  36.9 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.327
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.2.327
  11. Problem:    When formatting text all marks in the formatted lines are lost.
  12.         A word is not joined to a previous line when this would be
  13.         possible.  (Mikolaj Machowski)
  14. Solution:   Try to keep marks in the same position as much as possible.
  15.         Also keep mark positions when joining lines.
  16.         Start auto-formatting in the previous line when appropriate.
  17.         Add the "gw" operator: Like "gq" but keep the cursor where it is.
  18. Files:        runtime/doc/change.txt, src/edit.c, src/globals.h, src/mark.c,
  19.         src/misc1.c, src/normal.c, src/ops.c, src/proto/edit.pro,
  20.         src/proto/mark.pro, src/proto/ops.pro, src/structs.h, src/vim.h
  21.  
  22.  
  23. *** ../vim-6.2.326/runtime/doc/change.txt    Sun Jun  1 12:20:31 2003
  24. --- runtime/doc/change.txt    Thu Mar  4 23:02:55 2004
  25. ***************
  26. *** 1,4 ****
  27. ! *change.txt*    For Vim version 6.2.  Last change: 2003 May 24
  28.   
  29.   
  30.             VIM REFERENCE MANUAL    by Bram Moolenaar
  31. --- 1,4 ----
  32. ! *change.txt*    For Vim version 6.2.  Last change: 2004 Mar 04
  33.   
  34.   
  35.             VIM REFERENCE MANUAL    by Bram Moolenaar
  36. ***************
  37. *** 1104,1110 ****
  38.   {Visual}gq        Format the highlighted text.  (for {Visual} see
  39.               |Visual-mode|).  {not in Vi}
  40.   
  41. ! Example: To format the current paragraph use: >
  42.       gqap
  43.   
  44.   The "gq" command leaves the cursor in the line where the motion command takes
  45. --- 1128,1140 ----
  46.   {Visual}gq        Format the highlighted text.  (for {Visual} see
  47.               |Visual-mode|).  {not in Vi}
  48.   
  49. !                             *gw*
  50. ! gw{motion}        Format the lines that {motion} moves over.  Similar to
  51. !             |gq| but puts the cursor back at the same position in
  52. !             the text.  However, 'formatprg' is not used.
  53. !             {not in Vi}
  54. ! Example: To format the current paragraph use:            *gqap*  >
  55.       gqap
  56.   
  57.   The "gq" command leaves the cursor in the line where the motion command takes
  58. ***************
  59. *** 1112,1117 ****
  60. --- 1142,1152 ----
  61.   works well with "gqj" (format current and next line) and "gq}" (format until
  62.   end of paragraph).  Note: When 'formatprg' is set, "gq" leaves the cursor on
  63.   the first formatted line (as with using a filter command).
  64. + If you want to format the current paragraph and continue where you were, use: >
  65. +     gwap
  66. + If you always want to keep paragraphs formatted you may want to add the 'a'
  67. + flag to 'formatoptions'.  See |auto-format|.
  68.   
  69.   If the 'autoindent' option is on, Vim uses the indent of the first line for
  70.   the following lines.
  71. *** ../vim-6.2.326/src/edit.c    Tue Mar  2 14:59:39 2004
  72. --- src/edit.c    Mon Mar  8 11:55:50 2004
  73. ***************
  74. *** 122,130 ****
  75.   static void undisplay_dollar __ARGS((void));
  76.   static void insert_special __ARGS((int, int, int));
  77.   static void check_auto_format __ARGS((int));
  78. - #ifdef FEAT_COMMENTS
  79. - static int  cmplen __ARGS((char_u *s1, char_u *s2));
  80. - #endif
  81.   static void redo_literal __ARGS((int c));
  82.   static void start_arrow __ARGS((pos_T *end_insert_pos));
  83.   static void stop_insert __ARGS((pos_T *end_insert_pos, int esc));
  84. --- 122,127 ----
  85. ***************
  86. *** 874,880 ****
  87.       /* insert the contents of a register */
  88.       case Ctrl_R:
  89.           ins_reg();
  90. !         auto_format(FALSE);
  91.           inserted_space = FALSE;
  92.           break;
  93.   
  94. --- 871,877 ----
  95.       /* insert the contents of a register */
  96.       case Ctrl_R:
  97.           ins_reg();
  98. !         auto_format(FALSE, TRUE);
  99.           inserted_space = FALSE;
  100.           break;
  101.   
  102. ***************
  103. *** 969,975 ****
  104.           }
  105.   # endif
  106.           ins_shift(c, lastc);
  107. !         auto_format(FALSE);
  108.           inserted_space = FALSE;
  109.           break;
  110.   
  111. --- 966,972 ----
  112.           }
  113.   # endif
  114.           ins_shift(c, lastc);
  115. !         auto_format(FALSE, TRUE);
  116.           inserted_space = FALSE;
  117.           break;
  118.   
  119. ***************
  120. *** 977,1002 ****
  121.       case K_DEL:
  122.       case K_KDEL:
  123.           ins_del();
  124. !         auto_format(FALSE);
  125.           break;
  126.   
  127.       /* delete character before the cursor */
  128.       case K_BS:
  129.       case Ctrl_H:
  130.           did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space);
  131. !         auto_format(FALSE);
  132.           break;
  133.   
  134.       /* delete word before the cursor */
  135.       case Ctrl_W:
  136.           did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space);
  137. !         auto_format(FALSE);
  138.           break;
  139.   
  140.       /* delete all inserted text in current line */
  141.       case Ctrl_U:
  142.           did_backspace = ins_bs(c, BACKSPACE_LINE, &inserted_space);
  143. !         auto_format(FALSE);
  144.           inserted_space = FALSE;
  145.           break;
  146.   
  147. --- 974,999 ----
  148.       case K_DEL:
  149.       case K_KDEL:
  150.           ins_del();
  151. !         auto_format(FALSE, TRUE);
  152.           break;
  153.   
  154.       /* delete character before the cursor */
  155.       case K_BS:
  156.       case Ctrl_H:
  157.           did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space);
  158. !         auto_format(FALSE, TRUE);
  159.           break;
  160.   
  161.       /* delete word before the cursor */
  162.       case Ctrl_W:
  163.           did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space);
  164. !         auto_format(FALSE, TRUE);
  165.           break;
  166.   
  167.       /* delete all inserted text in current line */
  168.       case Ctrl_U:
  169.           did_backspace = ins_bs(c, BACKSPACE_LINE, &inserted_space);
  170. !         auto_format(FALSE, TRUE);
  171.           inserted_space = FALSE;
  172.           break;
  173.   
  174. ***************
  175. *** 1119,1125 ****
  176.           inserted_space = FALSE;
  177.           if (ins_tab())
  178.           goto normalchar;    /* insert TAB as a normal char */
  179. !         auto_format(FALSE);
  180.           break;
  181.   
  182.       case K_KENTER:
  183. --- 1116,1122 ----
  184.           inserted_space = FALSE;
  185.           if (ins_tab())
  186.           goto normalchar;    /* insert TAB as a normal char */
  187. !         auto_format(FALSE, TRUE);
  188.           break;
  189.   
  190.       case K_KENTER:
  191. ***************
  192. *** 1146,1152 ****
  193.   #endif
  194.           if (ins_eol(c) && !p_im)
  195.           goto doESCkey;        /* out of memory */
  196. !         auto_format(FALSE);
  197.           inserted_space = FALSE;
  198.           break;
  199.   
  200. --- 1143,1149 ----
  201.   #endif
  202.           if (ins_eol(c) && !p_im)
  203.           goto doESCkey;        /* out of memory */
  204. !         auto_format(FALSE, FALSE);
  205.           inserted_space = FALSE;
  206.           break;
  207.   
  208. ***************
  209. *** 1260,1266 ****
  210.               revins_legal++;
  211.   #endif
  212.               c = Ctrl_V;    /* pretend CTRL-V is last character */
  213. !             auto_format(FALSE);
  214.           }
  215.           }
  216.           break;
  217. --- 1257,1263 ----
  218.               revins_legal++;
  219.   #endif
  220.               c = Ctrl_V;    /* pretend CTRL-V is last character */
  221. !             auto_format(FALSE, TRUE);
  222.           }
  223.           }
  224.           break;
  225. ***************
  226. *** 1307,1313 ****
  227.   #endif
  228.           }
  229.   
  230. !         auto_format(FALSE);
  231.   
  232.   #ifdef FEAT_FOLDING
  233.           /* When inserting a character the cursor line must never be in a
  234. --- 1304,1310 ----
  235.   #endif
  236.           }
  237.   
  238. !         auto_format(FALSE, TRUE);
  239.   
  240.   #ifdef FEAT_FOLDING
  241.           /* When inserting a character the cursor line must never be in a
  242. ***************
  243. *** 1767,1774 ****
  244.       if (State & VREPLACE_FLAG)
  245.       {
  246.       /* If orig_line didn't allocate, just return.  At least we did the job,
  247. !      * even if you can't backspace.
  248. !      */
  249.       if (orig_line == NULL)
  250.           return;
  251.   
  252. --- 1764,1770 ----
  253.       if (State & VREPLACE_FLAG)
  254.       {
  255.       /* If orig_line didn't allocate, just return.  At least we did the job,
  256. !      * even if you can't backspace. */
  257.       if (orig_line == NULL)
  258.           return;
  259.   
  260. ***************
  261. *** 2509,2515 ****
  262.           curwin->w_cursor.col++;
  263.           }
  264.   
  265. !         auto_format(FALSE);
  266.   
  267.           ins_compl_free();
  268.           started_completion = FALSE;
  269. --- 2505,2511 ----
  270.           curwin->w_cursor.col++;
  271.           }
  272.   
  273. !         auto_format(FALSE, TRUE);
  274.   
  275.           ins_compl_free();
  276.           started_completion = FALSE;
  277. ***************
  278. *** 4114,4120 ****
  279.            * Split the line just before the margin.
  280.            * Only insert/delete lines, but don't really redraw the window.
  281.            */
  282. !         open_line(FORWARD, OPENLINE_DELSPACES
  283.               + (fo_white_par ? OPENLINE_KEEPTRAIL : 0)
  284.   #ifdef FEAT_COMMENTS
  285.               + (do_comments ? OPENLINE_DO_COM : 0)
  286. --- 4110,4116 ----
  287.            * Split the line just before the margin.
  288.            * Only insert/delete lines, but don't really redraw the window.
  289.            */
  290. !         open_line(FORWARD, OPENLINE_DELSPACES + OPENLINE_MARKFIX
  291.               + (fo_white_par ? OPENLINE_KEEPTRAIL : 0)
  292.   #ifdef FEAT_COMMENTS
  293.               + (do_comments ? OPENLINE_DO_COM : 0)
  294. ***************
  295. *** 4366,4377 ****
  296.    * saved here.
  297.    */
  298.       void
  299. ! auto_format(trailblank)
  300.       int        trailblank;    /* when TRUE also format with trailing blank */
  301.   {
  302.       pos_T    pos;
  303.       colnr_T    len;
  304. !     char_u    *old, *pold;
  305.       char_u    *new, *pnew;
  306.       int        wasatend;
  307.   
  308. --- 4362,4374 ----
  309.    * saved here.
  310.    */
  311.       void
  312. ! auto_format(trailblank, prev_line)
  313.       int        trailblank;    /* when TRUE also format with trailing blank */
  314. +     int        prev_line;    /* may start in previous line */
  315.   {
  316.       pos_T    pos;
  317.       colnr_T    len;
  318. !     char_u    *old;
  319.       char_u    *new, *pnew;
  320.       int        wasatend;
  321.   
  322. ***************
  323. *** 4413,4490 ****
  324.       return;
  325.   #endif
  326.   
  327. !     old = vim_strsave(old);
  328. !     format_lines((linenr_T)-1);
  329.   
  330. !     /* Advance to the same text position again.  This is tricky, indents
  331. !      * may have changed and comment leaders may have been inserted. */
  332. !     curwin->w_cursor.lnum = pos.lnum;
  333. !     curwin->w_cursor.col = 0;
  334. !     pold = old;
  335. !     while (1)
  336. !     {
  337. !     if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
  338. !     {
  339. !         curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
  340. !         curwin->w_cursor.col = MAXCOL;
  341. !         break;
  342. !     }
  343. !     /* Make "pold" and "pnew" point to the start of the line, ignoring
  344. !      * indent and comment leader. */
  345. !     pold = skipwhite(pold);
  346. !     new = ml_get_curline();
  347. !     pnew = skipwhite(new);
  348. ! #ifdef FEAT_COMMENTS
  349. !     len = get_leader_len(new, NULL, FALSE);
  350. !     if (len > 0)
  351. !     {
  352. !         char_u    *p;
  353.   
  354. !         /* Skip the leader if the old text matches after it, ignoring
  355. !          * white space.  Keep in mind that the leader may appear in
  356. !          * the text! */
  357. !         p = skipwhite(new + len);
  358. !         if (cmplen(pold, pnew) < cmplen(pold, p))
  359. !         pnew = p;
  360. !     }
  361. ! #endif
  362.   
  363. !     len = (colnr_T)STRLEN(pnew);
  364. !     if ((pold - old) + len >= pos.col)
  365.       {
  366. !         if (pos.col <= (colnr_T)(pold - old))
  367. !         curwin->w_cursor.col = (pnew - new);
  368. !         else
  369. !         curwin->w_cursor.col = pos.col - (pold - old) + (pnew - new);
  370. !         /* Insert mode: If the cursor is now after the end of the line
  371. !          * while it previously wasn't, the line was broken.  Because of
  372. !          * the rule above we need to add a space when 'w' is in
  373. !          * 'formatoptions' to keep a paragraph formatted. */
  374. !         if (!wasatend && has_format_option(FO_WHITE_PAR))
  375. !         {
  376. !         len = STRLEN(new);
  377. !         if (curwin->w_cursor.col == len)
  378. !         {
  379. !             pnew = vim_strnsave(new, len + 2);
  380. !             pnew[len] = ' ';
  381. !             pnew[len + 1] = NUL;
  382. !             ml_replace(curwin->w_cursor.lnum, pnew, FALSE);
  383. !             /* remove the space later */
  384. !             did_add_space = TRUE;
  385. !         }
  386. !         else
  387. !             /* may remove added space */
  388. !             check_auto_format(FALSE);
  389. !         }
  390. !         break;
  391.       }
  392. !     /* Cursor wraps to next line */
  393. !     ++curwin->w_cursor.lnum;
  394. !     pold += len;
  395.       }
  396.       check_cursor();
  397. -     vim_free(old);
  398.   }
  399.   
  400.   /*
  401. --- 4410,4468 ----
  402.       return;
  403.   #endif
  404.   
  405. !     /*
  406. !      * May start formatting in a previous line, so that after "x" a word is
  407. !      * moved to the previous line if it fits there now.  Only when this is not
  408. !      * the start of a paragraph.
  409. !      */
  410. !     if (prev_line && !paragraph_start(curwin->w_cursor.lnum))
  411. !     {
  412. !     --curwin->w_cursor.lnum;
  413. !     if (u_save_cursor() == FAIL)
  414. !         return;
  415. !     }
  416.   
  417. !     /*
  418. !      * Do the formatting and restore the cursor position.  "saved_cursor" will
  419. !      * be adjusted for the text formatting.
  420. !      */
  421. !     saved_cursor = pos;
  422. !     format_lines((linenr_T)-1);
  423. !     curwin->w_cursor = saved_cursor;
  424. !     saved_cursor.lnum = 0;
  425.   
  426. !     if (curwin->w_cursor.lnum > curbuf->b_ml.ml_line_count)
  427. !     {
  428. !     /* "cannot happen" */
  429. !     curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
  430. !     coladvance((colnr_T)MAXCOL);
  431. !     }
  432. !     else
  433. !     check_cursor_col();
  434.   
  435. !     /* Insert mode: If the cursor is now after the end of the line while it
  436. !      * previously wasn't, the line was broken.  Because of the rule above we
  437. !      * need to add a space when 'w' is in 'formatoptions' to keep a paragraph
  438. !      * formatted. */
  439. !     if (!wasatend && has_format_option(FO_WHITE_PAR))
  440. !     {
  441. !     new = ml_get_curline();
  442. !     len = STRLEN(new);
  443. !     if (curwin->w_cursor.col == len)
  444.       {
  445. !         pnew = vim_strnsave(new, len + 2);
  446. !         pnew[len] = ' ';
  447. !         pnew[len + 1] = NUL;
  448. !         ml_replace(curwin->w_cursor.lnum, pnew, FALSE);
  449. !         /* remove the space later */
  450. !         did_add_space = TRUE;
  451.       }
  452. !     else
  453. !         /* may remove added space */
  454. !         check_auto_format(FALSE);
  455.       }
  456.       check_cursor();
  457.   }
  458.   
  459.   /*
  460. ***************
  461. *** 4521,4552 ****
  462.       }
  463.   }
  464.   
  465. - #ifdef FEAT_COMMENTS
  466. - /*
  467. -  * Return the number of bytes for which strings "s1" and "s2" are equal.
  468. -  */
  469. -     static int
  470. - cmplen(s1, s2)
  471. -     char_u    *s1;
  472. -     char_u    *s2;
  473. - {
  474. -     char_u    *p1 = s1, *p2 = s2;
  475. -     while (*p1 == *p2 && *p1 != NUL)
  476. -     {
  477. -     ++p1;
  478. -     ++p2;
  479. -     }
  480. -     return (int)(p1 - s1);
  481. - }
  482. - #endif
  483.   /*
  484.    * Find out textwidth to be used for formatting:
  485.    *    if 'textwidth' option is set, use it
  486.    *    else if 'wrapmargin' option is set, use W_WIDTH(curwin) - 'wrapmargin'
  487.    *    if invalid value, use 0.
  488. !  *    Set default to window width (maximum 79) for "Q" command.
  489.    */
  490.       int
  491.   comp_textwidth(ff)
  492. --- 4499,4510 ----
  493.       }
  494.   }
  495.   
  496.   /*
  497.    * Find out textwidth to be used for formatting:
  498.    *    if 'textwidth' option is set, use it
  499.    *    else if 'wrapmargin' option is set, use W_WIDTH(curwin) - 'wrapmargin'
  500.    *    if invalid value, use 0.
  501. !  *    Set default to window width (maximum 79) for "gq" operator.
  502.    */
  503.       int
  504.   comp_textwidth(ff)
  505. ***************
  506. *** 4694,4700 ****
  507.        * a line and having it end in a space.  But only do it when something
  508.        * was actually inserted, otherwise undo won't work. */
  509.       if (!ins_need_undo)
  510. !         auto_format(TRUE);
  511.   
  512.       /* If a space was inserted for auto-formatting, remove it now. */
  513.       check_auto_format(TRUE);
  514. --- 4652,4675 ----
  515.        * a line and having it end in a space.  But only do it when something
  516.        * was actually inserted, otherwise undo won't work. */
  517.       if (!ins_need_undo)
  518. !     {
  519. !         /* When the cursor is at the end of the line after a space the
  520. !          * formatting will move it to the following word.  Avoid that by
  521. !          * moving the cursor onto the space. */
  522. !         cc = 'x';
  523. !         if (curwin->w_cursor.col > 0 == NUL && gchar_cursor())
  524. !         {
  525. !         dec_cursor();
  526. !         cc = gchar_cursor();
  527. !         if (!vim_iswhite(cc))
  528. !             inc_cursor();
  529. !         }
  530. !         auto_format(TRUE, FALSE);
  531. !         if (vim_iswhite(cc) && gchar_cursor() != NUL)
  532. !         inc_cursor();
  533. !     }
  534.   
  535.       /* If a space was inserted for auto-formatting, remove it now. */
  536.       check_auto_format(TRUE);
  537. *** ../vim-6.2.326/src/globals.h    Sat Mar  6 21:10:59 2004
  538. --- src/globals.h    Sat Mar  6 15:13:54 2004
  539. ***************
  540. *** 608,613 ****
  541. --- 608,619 ----
  542.   EXTERN int    can_si_back INIT(= FALSE);
  543.   #endif
  544.   
  545. + EXTERN pos_T    saved_cursor        /* w_cursor before formatting text. */
  546. + # ifdef DO_INIT
  547. +     = INIT_POS_T
  548. + # endif
  549. +     ;
  550.   /*
  551.    * Stuff for insert mode.
  552.    */
  553. *** ../vim-6.2.326/src/mark.c    Tue Mar  2 16:04:09 2004
  554. --- src/mark.c    Thu Mar  4 13:50:05 2004
  555. ***************
  556. *** 923,928 ****
  557. --- 923,932 ----
  558.       /* previous pcmark */
  559.       one_adjust(&(curwin->w_prev_pcmark.lnum));
  560.   
  561. +     /* saved cursor for formatting */
  562. +     if (saved_cursor.lnum != 0)
  563. +     one_adjust_nodel(&(saved_cursor.lnum));
  564.       /*
  565.        * Adjust items in all windows related to the current buffer.
  566.        */
  567. ***************
  568. *** 1008,1013 ****
  569. --- 1012,1117 ----
  570.       /* adjust diffs */
  571.       diff_mark_adjust(line1, line2, amount, amount_after);
  572.   #endif
  573. + }
  574. + /* This code is used often, needs to be fast. */
  575. + #define col_adjust(pp) \
  576. +     { \
  577. +     posp = pp; \
  578. +     if (posp->lnum == lnum && posp->col >= mincol) \
  579. +     { \
  580. +         posp->lnum += lnum_amount; \
  581. +         if (col_amount < 0 && posp->col <= (colnr_T)-col_amount) \
  582. +         posp->col = 0; \
  583. +         else \
  584. +         posp->col += col_amount; \
  585. +     } \
  586. +     }
  587. + /*
  588. +  * Adjust marks in line "lnum" at column "mincol" and further: add
  589. +  * "lnum_amount" to the line number and add "col_amount" to the column
  590. +  * position.
  591. +  */
  592. +     void
  593. + mark_col_adjust(lnum, mincol, lnum_amount, col_amount)
  594. +     linenr_T    lnum;
  595. +     colnr_T    mincol;
  596. +     long    lnum_amount;
  597. +     long    col_amount;
  598. + {
  599. +     int        i;
  600. +     int        fnum = curbuf->b_fnum;
  601. +     win_T    *win;
  602. +     pos_T    *posp;
  603. +     if ((col_amount == 0L && lnum_amount == 0L) || cmdmod.lockmarks)
  604. +     return; /* nothing to do */
  605. +     /* named marks, lower case and upper case */
  606. +     for (i = 0; i < NMARKS; i++)
  607. +     {
  608. +     col_adjust(&(curbuf->b_namedm[i]));
  609. +     if (namedfm[i].fmark.fnum == fnum)
  610. +         col_adjust(&(namedfm[i].fmark.mark));
  611. +     }
  612. +     for (i = NMARKS; i < NMARKS + EXTRA_MARKS; i++)
  613. +     {
  614. +     if (namedfm[i].fmark.fnum == fnum)
  615. +         col_adjust(&(namedfm[i].fmark.mark));
  616. +     }
  617. +     /* last Insert position */
  618. +     col_adjust(&(curbuf->b_last_insert));
  619. +     /* last change position */
  620. +     col_adjust(&(curbuf->b_last_change));
  621. + #ifdef FEAT_JUMPLIST
  622. +     /* list of change positions */
  623. +     for (i = 0; i < curbuf->b_changelistlen; ++i)
  624. +     col_adjust(&(curbuf->b_changelist[i]));
  625. + #endif
  626. + #ifdef FEAT_VISUAL
  627. +     /* Visual area */
  628. +     col_adjust(&(curbuf->b_visual_start));
  629. +     col_adjust(&(curbuf->b_visual_end));
  630. + #endif
  631. +     /* previous context mark */
  632. +     col_adjust(&(curwin->w_pcmark));
  633. +     /* previous pcmark */
  634. +     col_adjust(&(curwin->w_prev_pcmark));
  635. +     /* saved cursor for formatting */
  636. +     col_adjust(&saved_cursor);
  637. +     /*
  638. +      * Adjust items in all windows related to the current buffer.
  639. +      */
  640. +     FOR_ALL_WINDOWS(win)
  641. +     {
  642. + #ifdef FEAT_JUMPLIST
  643. +     /* marks in the jumplist */
  644. +     for (i = 0; i < win->w_jumplistlen; ++i)
  645. +         if (win->w_jumplist[i].fmark.fnum == fnum)
  646. +         col_adjust(&(win->w_jumplist[i].fmark.mark));
  647. + #endif
  648. +     if (win->w_buffer == curbuf)
  649. +     {
  650. +         /* marks in the tag stack */
  651. +         for (i = 0; i < win->w_tagstacklen; i++)
  652. +         if (win->w_tagstack[i].fmark.fnum == fnum)
  653. +             col_adjust(&(win->w_tagstack[i].fmark.mark));
  654. +         /* cursor position for other windows with the same buffer */
  655. +         if (win != curwin)
  656. +         col_adjust(&win->w_cursor);
  657. +     }
  658. +     }
  659.   }
  660.   
  661.   #ifdef FEAT_JUMPLIST
  662. *** ../vim-6.2.326/src/misc1.c    Sun Mar  7 15:21:39 2004
  663. --- src/misc1.c    Mon Mar  8 10:27:17 2004
  664. ***************
  665. *** 95,101 ****
  666.       int        flags;
  667.   {
  668.       char_u    *p;
  669. !     char_u    *line;
  670.       char_u    *s;
  671.       int        todo;
  672.       int        ind_len;
  673. --- 95,102 ----
  674.       int        flags;
  675.   {
  676.       char_u    *p;
  677. !     char_u    *newline;
  678. !     char_u    *oldline;
  679.       char_u    *s;
  680.       int        todo;
  681.       int        ind_len;
  682. ***************
  683. *** 110,116 ****
  684.        */
  685.       todo = size;
  686.       ind_len = 0;
  687. !     p = ml_get_curline();
  688.   
  689.       /* Calculate the buffer size for the new indent, and check to see if it
  690.        * isn't already set */
  691. --- 111,117 ----
  692.        */
  693.       todo = size;
  694.       ind_len = 0;
  695. !     p = oldline = ml_get_curline();
  696.   
  697.       /* Calculate the buffer size for the new indent, and check to see if it
  698.        * isn't already set */
  699. ***************
  700. *** 188,203 ****
  701.   
  702.       /* Allocate memory for the new line. */
  703.       if (flags & SIN_INSERT)
  704. !     p = ml_get_curline();
  705.       else
  706.       p = skipwhite(p);
  707.       line_len = (int)STRLEN(p) + 1;
  708. !     line = alloc(ind_len + line_len);
  709. !     if (line == NULL)
  710.       return FALSE;
  711.   
  712.       /* Put the characters in the new line. */
  713. !     s = line;
  714.       todo = size;
  715.       /* if 'expandtab' isn't set: use TABs */
  716.       if (!curbuf->b_p_et)
  717. --- 189,204 ----
  718.   
  719.       /* Allocate memory for the new line. */
  720.       if (flags & SIN_INSERT)
  721. !     p = oldline;
  722.       else
  723.       p = skipwhite(p);
  724.       line_len = (int)STRLEN(p) + 1;
  725. !     newline = alloc(ind_len + line_len);
  726. !     if (newline == NULL)
  727.       return FALSE;
  728.   
  729.       /* Put the characters in the new line. */
  730. !     s = newline;
  731.       todo = size;
  732.       /* if 'expandtab' isn't set: use TABs */
  733.       if (!curbuf->b_p_et)
  734. ***************
  735. *** 206,212 ****
  736.        * the existing indent structure for the new indent */
  737.       if (!(flags & SIN_INSERT) && curbuf->b_p_pi)
  738.       {
  739. !         p = ml_get_curline();
  740.           ind_done = 0;
  741.   
  742.           while (todo > 0 && vim_iswhite(*p))
  743. --- 207,213 ----
  744.        * the existing indent structure for the new indent */
  745.       if (!(flags & SIN_INSERT) && curbuf->b_p_pi)
  746.       {
  747. !         p = oldline;
  748.           ind_done = 0;
  749.   
  750.           while (todo > 0 && vim_iswhite(*p))
  751. ***************
  752. *** 256,267 ****
  753.       /* Replace the line (unless undo fails). */
  754.       if (!(flags & SIN_UNDO) || u_savesub(curwin->w_cursor.lnum) == OK)
  755.       {
  756. !     ml_replace(curwin->w_cursor.lnum, line, FALSE);
  757.       if (flags & SIN_CHANGED)
  758.           changed_bytes(curwin->w_cursor.lnum, 0);
  759.       }
  760.       else
  761. !     vim_free(line);
  762.   
  763.       curwin->w_cursor.col = ind_len;
  764.       return TRUE;
  765. --- 257,272 ----
  766.       /* Replace the line (unless undo fails). */
  767.       if (!(flags & SIN_UNDO) || u_savesub(curwin->w_cursor.lnum) == OK)
  768.       {
  769. !     ml_replace(curwin->w_cursor.lnum, newline, FALSE);
  770.       if (flags & SIN_CHANGED)
  771.           changed_bytes(curwin->w_cursor.lnum, 0);
  772. +     /* Correct saved cursor position if it's after the indent. */
  773. +     if (saved_cursor.lnum == curwin->w_cursor.lnum
  774. +                 && saved_cursor.col >= (colnr_T)(p - oldline))
  775. +         saved_cursor.col += ind_len - (p - oldline);
  776.       }
  777.       else
  778. !     vim_free(newline);
  779.   
  780.       curwin->w_cursor.col = ind_len;
  781.       return TRUE;
  782. ***************
  783. *** 373,379 ****
  784.   
  785.   /*
  786.    * Return the indent of the current line after a number.  Return -1 if no
  787. !  * number was found.  Used for '1' in 'formatoptions': numbered list.
  788.    */
  789.       int
  790.   get_number_indent(lnum)
  791. --- 378,384 ----
  792.   
  793.   /*
  794.    * Return the indent of the current line after a number.  Return -1 if no
  795. !  * number was found.  Used for 'n' in 'formatoptions': numbered list.
  796.    */
  797.       int
  798.   get_number_indent(lnum)
  799. ***************
  800. *** 449,466 ****
  801.    * Caller must take care of undo.  Since VREPLACE may affect any number of
  802.    * lines however, it may call u_save_cursor() again when starting to change a
  803.    * new line.
  804.    *
  805.    * Return TRUE for success, FALSE for failure
  806.    */
  807.       int
  808.   open_line(dir, flags, old_indent)
  809.       int        dir;        /* FORWARD or BACKWARD */
  810. !     int        flags;        /* OPENLINE_DELSPACES and OPENLINE_DO_COM */
  811.       int        old_indent;    /* indent for after ^^D in Insert mode */
  812.   {
  813.       char_u    *saved_line;        /* copy of the original line */
  814.       char_u    *next_line = NULL;    /* copy of the next line */
  815.       char_u    *p_extra = NULL;    /* what goes to next line */
  816.       pos_T    old_cursor;        /* old cursor position */
  817.       int        newcol = 0;        /* new cursor column */
  818.       int        newindent = 0;        /* auto-indent of the new line */
  819. --- 454,477 ----
  820.    * Caller must take care of undo.  Since VREPLACE may affect any number of
  821.    * lines however, it may call u_save_cursor() again when starting to change a
  822.    * new line.
  823. +  * "flags": OPENLINE_DELSPACES    delete spaces after cursor
  824. +  *        OPENLINE_DO_COM    format comments
  825. +  *        OPENLINE_KEEPTRAIL    keep trailing spaces
  826. +  *        OPENLINE_MARKFIX    adjust mark positions after the line break
  827.    *
  828.    * Return TRUE for success, FALSE for failure
  829.    */
  830.       int
  831.   open_line(dir, flags, old_indent)
  832.       int        dir;        /* FORWARD or BACKWARD */
  833. !     int        flags;
  834.       int        old_indent;    /* indent for after ^^D in Insert mode */
  835.   {
  836.       char_u    *saved_line;        /* copy of the original line */
  837.       char_u    *next_line = NULL;    /* copy of the next line */
  838.       char_u    *p_extra = NULL;    /* what goes to next line */
  839. +     int        less_cols = 0;        /* less columns for mark in new line */
  840. +     int        less_cols_off = 0;    /* columns to skip for mark adjust */
  841.       pos_T    old_cursor;        /* old cursor position */
  842.       int        newcol = 0;        /* new cursor column */
  843.       int        newindent = 0;        /* auto-indent of the new line */
  844. ***************
  845. *** 1138,1147 ****
  846. --- 1149,1162 ----
  847.           if (REPLACE_NORMAL(State))
  848.               replace_push(*p_extra);
  849.           ++p_extra;
  850. +         ++less_cols_off;
  851.           }
  852.       }
  853.       if (*p_extra != NUL)
  854.           did_ai = FALSE;        /* append some text, don't truncate now */
  855. +     /* columns for marks adjusted for removed columns */
  856. +     less_cols = (int)(p_extra - saved_line);
  857.       }
  858.   
  859.       if (p_extra == NULL)
  860. ***************
  861. *** 1154,1159 ****
  862. --- 1169,1175 ----
  863.       STRCAT(leader, p_extra);
  864.       p_extra = leader;
  865.       did_ai = TRUE;        /* So truncating blanks works with comments */
  866. +     less_cols -= lead_len;
  867.       }
  868.       else
  869.       end_comment_pending = NUL;  /* turns out there was no leader */
  870. ***************
  871. *** 1225,1230 ****
  872. --- 1241,1247 ----
  873.       }
  874.       else
  875.           (void)set_indent(newindent, SIN_INSERT);
  876. +     less_cols -= curwin->w_cursor.col;
  877.   
  878.       ai_col = curwin->w_cursor.col;
  879.   
  880. ***************
  881. *** 1270,1275 ****
  882. --- 1287,1298 ----
  883.           changed_lines(curwin->w_cursor.lnum, curwin->w_cursor.col,
  884.                              curwin->w_cursor.lnum + 1, 1L);
  885.           did_append = FALSE;
  886. +         /* Move marks after the line break to the new line. */
  887. +         if (flags & OPENLINE_MARKFIX)
  888. +             mark_col_adjust(curwin->w_cursor.lnum,
  889. +                      curwin->w_cursor.col + less_cols_off,
  890. +                             1L, (long)-less_cols);
  891.           }
  892.           else
  893.           changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
  894. ***************
  895. *** 2309,2318 ****
  896.       void
  897.   changed()
  898.   {
  899. -     int        save_msg_scroll = msg_scroll;
  900.       if (!curbuf->b_changed)
  901.       {
  902.       change_warning(0);
  903.       /* Create a swap file if that is wanted.
  904.        * Don't do this for "nofile" and "nowrite" buffer types. */
  905. --- 2332,2341 ----
  906.       void
  907.   changed()
  908.   {
  909.       if (!curbuf->b_changed)
  910.       {
  911. +     int    save_msg_scroll = msg_scroll;
  912.       change_warning(0);
  913.       /* Create a swap file if that is wanted.
  914.        * Don't do this for "nofile" and "nowrite" buffer types. */
  915. *** ../vim-6.2.326/src/normal.c    Fri Mar  5 12:12:37 2004
  916. --- src/normal.c    Mon Mar  8 10:11:06 2004
  917. ***************
  918. *** 1792,1798 ****
  919.               oap->is_VIsual ? (int)cap->count1 :
  920.   #endif
  921.               1);
  922. !         auto_format(FALSE);
  923.           break;
  924.   
  925.       case OP_JOIN_NS:
  926. --- 1792,1798 ----
  927.               oap->is_VIsual ? (int)cap->count1 :
  928.   #endif
  929.               1);
  930. !         auto_format(FALSE, TRUE);
  931.           break;
  932.   
  933.       case OP_JOIN_NS:
  934. ***************
  935. *** 1805,1811 ****
  936.           else
  937.           {
  938.           do_do_join(oap->line_count, oap->op_type == OP_JOIN);
  939. !         auto_format(FALSE);
  940.           }
  941.           break;
  942.   
  943. --- 1805,1811 ----
  944.           else
  945.           {
  946.           do_do_join(oap->line_count, oap->op_type == OP_JOIN);
  947. !         auto_format(FALSE, TRUE);
  948.           }
  949.           break;
  950.   
  951. ***************
  952. *** 1820,1826 ****
  953.           (void)op_delete(oap);
  954.           if (oap->motion_type == MLINE && has_format_option(FO_AUTO))
  955.               u_save_cursor();        /* cursor line wasn't saved yet */
  956. !         auto_format(FALSE);
  957.           }
  958.           break;
  959.   
  960. --- 1820,1826 ----
  961.           (void)op_delete(oap);
  962.           if (oap->motion_type == MLINE && has_format_option(FO_AUTO))
  963.               u_save_cursor();        /* cursor line wasn't saved yet */
  964. !         auto_format(FALSE, TRUE);
  965.           }
  966.           break;
  967.   
  968. ***************
  969. *** 1912,1918 ****
  970.           if (*p_fp != NUL)
  971.           op_colon(oap);        /* use external command */
  972.           else
  973. !         op_format(oap);        /* use internal function */
  974.           break;
  975.   
  976.       case OP_INSERT:
  977. --- 1912,1922 ----
  978.           if (*p_fp != NUL)
  979.           op_colon(oap);        /* use external command */
  980.           else
  981. !         op_format(oap, FALSE);    /* use internal function */
  982. !         break;
  983. !     case OP_FORMAT2:
  984. !         op_format(oap, TRUE);    /* use internal function */
  985.           break;
  986.   
  987.       case OP_INSERT:
  988. ***************
  989. *** 1935,1941 ****
  990.   
  991.           /* TODO: when inserting in several lines, should format all
  992.            * the lines. */
  993. !         auto_format(FALSE);
  994.   
  995.           if (restart_edit == 0)
  996.               restart_edit = restart_edit_save;
  997. --- 1939,1945 ----
  998.   
  999.           /* TODO: when inserting in several lines, should format all
  1000.            * the lines. */
  1001. !         auto_format(FALSE, TRUE);
  1002.   
  1003.           if (restart_edit == 0)
  1004.               restart_edit = restart_edit_save;
  1005. ***************
  1006. *** 7278,7289 ****
  1007. --- 7285,7298 ----
  1008.       /*
  1009.        *     Two-character operators:
  1010.        *     "gq"        Format text
  1011. +      *     "gw"        Format text and keep cursor position
  1012.        *     "g~"        Toggle the case of the text.
  1013.        *     "gu"        Change text to lower case.
  1014.        *     "gU"        Change text to upper case.
  1015.        *   "g?"        rot13 encoding
  1016.        */
  1017.       case 'q':
  1018. +     case 'w':
  1019.       case '~':
  1020.       case 'u':
  1021.       case 'U':
  1022. ***************
  1023. *** 8298,8304 ****
  1024.       if (reg2 != NULL)
  1025.           put_register(regname, reg2);
  1026.   #endif
  1027. !     auto_format(FALSE);
  1028.       }
  1029.   }
  1030.   
  1031. --- 8307,8313 ----
  1032.       if (reg2 != NULL)
  1033.           put_register(regname, reg2);
  1034.   #endif
  1035. !     auto_format(FALSE, TRUE);
  1036.       }
  1037.   }
  1038.   
  1039. *** ../vim-6.2.326/src/ops.c    Wed Mar  3 23:01:29 2004
  1040. --- src/ops.c    Thu Mar  4 22:54:41 2004
  1041. ***************
  1042. *** 163,168 ****
  1043. --- 163,169 ----
  1044.       {'z', 'C', TRUE},    /* OP_FOLDCLOSEREC */
  1045.       {'z', 'd', TRUE},    /* OP_FOLDDEL */
  1046.       {'z', 'D', TRUE},    /* OP_FOLDDELREC */
  1047. +     {'g', 'w', TRUE},    /* OP_FORMAT2 */
  1048.   };
  1049.   
  1050.   /*
  1051. ***************
  1052. *** 3845,3851 ****
  1053.       int        insert_space;
  1054.   {
  1055.       char_u    *curr;
  1056. !     char_u    *next;
  1057.       char_u    *newp;
  1058.       int        endcurr1, endcurr2;
  1059.       int        currsize;    /* size of the current line */
  1060. --- 3846,3852 ----
  1061.       int        insert_space;
  1062.   {
  1063.       char_u    *curr;
  1064. !     char_u    *next, *next_start;
  1065.       char_u    *newp;
  1066.       int        endcurr1, endcurr2;
  1067.       int        currsize;    /* size of the current line */
  1068. ***************
  1069. *** 3883,3889 ****
  1070.       }
  1071.       }
  1072.   
  1073. !     next = ml_get((linenr_T)(curwin->w_cursor.lnum + 1));
  1074.       spaces = 0;
  1075.       if (insert_space)
  1076.       {
  1077. --- 3884,3890 ----
  1078.       }
  1079.       }
  1080.   
  1081. !     next = next_start = ml_get((linenr_T)(curwin->w_cursor.lnum + 1));
  1082.       spaces = 0;
  1083.       if (insert_space)
  1084.       {
  1085. ***************
  1086. *** 3939,3946 ****
  1087. --- 3940,3953 ----
  1088.        * Delete the following line. To do this we move the cursor there
  1089.        * briefly, and then move it back. After del_lines() the cursor may
  1090.        * have moved up (last line deleted), so the current lnum is kept in t.
  1091. +      *
  1092. +      * Move marks from the deleted line to the joined line, adjusting the
  1093. +      * column.  This is not Vi compatible, but Vi deletes the marks, thus that
  1094. +      * should not really be a problem.
  1095.        */
  1096.       t = curwin->w_cursor.lnum;
  1097. +     mark_col_adjust(t + 1, (colnr_T)0, (linenr_T)-1,
  1098. +                  (long)(currsize + spaces - (next - next_start)));
  1099.       ++curwin->w_cursor.lnum;
  1100.       del_lines(1L, FALSE);
  1101.       curwin->w_cursor.lnum = t;
  1102. ***************
  1103. *** 4039,4046 ****
  1104.    * implementation of the format operator 'gq'
  1105.    */
  1106.       void
  1107. ! op_format(oap)
  1108.       oparg_T    *oap;
  1109.   {
  1110.       long    old_line_count = curbuf->b_ml.ml_line_count;
  1111.   
  1112. --- 4046,4054 ----
  1113.    * implementation of the format operator 'gq'
  1114.    */
  1115.       void
  1116. ! op_format(oap, keep_cursor)
  1117.       oparg_T    *oap;
  1118. +     int        keep_cursor;        /* keep cursor on same text char */
  1119.   {
  1120.       long    old_line_count = curbuf->b_ml.ml_line_count;
  1121.   
  1122. ***************
  1123. *** 4057,4062 ****
  1124. --- 4065,4073 ----
  1125.       /* Set '[ mark at the start of the formatted area */
  1126.       curbuf->b_op_start = oap->start;
  1127.   
  1128. +     if (keep_cursor)
  1129. +     saved_cursor = curwin->w_cursor;
  1130.       format_lines(oap->line_count);
  1131.   
  1132.       /*
  1133. ***************
  1134. *** 4073,4078 ****
  1135. --- 4084,4095 ----
  1136.       /* put '] mark on the end of the formatted area */
  1137.       curbuf->b_op_end = curwin->w_cursor;
  1138.   
  1139. +     if (keep_cursor)
  1140. +     {
  1141. +     curwin->w_cursor = saved_cursor;
  1142. +     saved_cursor.lnum = 0;
  1143. +     }
  1144.   #ifdef FEAT_VISUAL
  1145.       if (oap->is_VIsual)
  1146.       {
  1147. ***************
  1148. *** 4301,4306 ****
  1149. --- 4318,4326 ----
  1150.               break;
  1151.   #ifdef FEAT_COMMENTS
  1152.           (void)del_bytes((long)next_leader_len, FALSE);
  1153. +         if (next_leader_len > 0)
  1154. +             mark_col_adjust(curwin->w_cursor.lnum, (colnr_T)0, 0L,
  1155. +                               (long)-next_leader_len);
  1156.   #endif
  1157.           curwin->w_cursor.lnum--;
  1158.           if (do_join(TRUE) == FAIL)
  1159. ***************
  1160. *** 4385,4390 ****
  1161. --- 4405,4466 ----
  1162.       return (*skipwhite(ml_get(lnum)) == NUL || startPS(lnum, NUL, FALSE));
  1163.   }
  1164.   #endif
  1165. + /*
  1166. +  * Return TRUE when a paragraph starts in line "lnum".  Return FALSE when the
  1167. +  * previous line is in the same paragraph.  Used for auto-formatting.
  1168. +  */
  1169. +     int
  1170. + paragraph_start(lnum)
  1171. +     linenr_T    lnum;
  1172. + {
  1173. +     char_u    *p;
  1174. + #ifdef FEAT_COMMENTS
  1175. +     int        leader_len = 0;        /* leader len of current line */
  1176. +     char_u    *leader_flags = NULL;    /* flags for leader of current line */
  1177. +     int        next_leader_len;    /* leader len of next line */
  1178. +     char_u    *next_leader_flags;    /* flags for leader of next line */
  1179. +     int        do_comments;        /* format comments */
  1180. + #endif
  1181. +     if (lnum <= 1)
  1182. +     return TRUE;        /* start of the file */
  1183. +     p = ml_get(lnum - 1);
  1184. +     if (*p == NUL)
  1185. +     return TRUE;        /* after empty line */
  1186. + #ifdef FEAT_COMMENTS
  1187. +     do_comments = has_format_option(FO_Q_COMS);
  1188. + #endif
  1189. +     if (fmt_check_par(lnum - 1
  1190. + #ifdef FEAT_COMMENTS
  1191. +                 , &leader_len, &leader_flags, do_comments
  1192. + #endif
  1193. +         ))
  1194. +     return TRUE;        /* after non-paragraph line */
  1195. +     if (fmt_check_par(lnum
  1196. + #ifdef FEAT_COMMENTS
  1197. +                , &next_leader_len, &next_leader_flags, do_comments
  1198. + #endif
  1199. +         ))
  1200. +     return TRUE;        /* "lnum" is not a paragraph line */
  1201. +     if (has_format_option(FO_WHITE_PAR) && !ends_in_white(lnum - 1))
  1202. +     return TRUE;        /* missing trailing space in previous line. */
  1203. +     if (has_format_option(FO_Q_NUMBER) && (get_number_indent(lnum) > 0))
  1204. +     return TRUE;        /* numbered item starts in "lnum". */
  1205. + #ifdef FEAT_COMMENTS
  1206. +     if (!same_leader(leader_len, leader_flags,
  1207. +                       next_leader_len, next_leader_flags))
  1208. +     return TRUE;        /* change of comment leader. */
  1209. + #endif
  1210. +     return FALSE;
  1211. + }
  1212.   
  1213.   #ifdef FEAT_VISUAL
  1214.   /*
  1215. *** ../vim-6.2.326/src/proto/edit.pro    Sun Jan 18 20:28:27 2004
  1216. --- src/proto/edit.pro    Mon Mar  8 10:11:10 2004
  1217. ***************
  1218. *** 13,19 ****
  1219.   void ins_compl_check_keys __ARGS((void));
  1220.   int get_literal __ARGS((void));
  1221.   void insertchar __ARGS((int c, int flags, int second_indent));
  1222. ! void auto_format __ARGS((int trailblank));
  1223.   int comp_textwidth __ARGS((int ff));
  1224.   int stop_arrow __ARGS((void));
  1225.   void set_last_insert __ARGS((int c));
  1226. --- 13,19 ----
  1227.   void ins_compl_check_keys __ARGS((void));
  1228.   int get_literal __ARGS((void));
  1229.   void insertchar __ARGS((int c, int flags, int second_indent));
  1230. ! void auto_format __ARGS((int trailblank, int prev_line));
  1231.   int comp_textwidth __ARGS((int ff));
  1232.   int stop_arrow __ARGS((void));
  1233.   void set_last_insert __ARGS((int c));
  1234. *** ../vim-6.2.326/src/proto/mark.pro    Sun Feb 29 20:46:43 2004
  1235. --- src/proto/mark.pro    Tue Mar  2 21:23:55 2004
  1236. ***************
  1237. *** 14,19 ****
  1238. --- 14,20 ----
  1239.   void ex_jumps __ARGS((exarg_T *eap));
  1240.   void ex_changes __ARGS((exarg_T *eap));
  1241.   void mark_adjust __ARGS((linenr_T line1, linenr_T line2, long amount, long amount_after));
  1242. + void mark_col_adjust __ARGS((linenr_T lnum, colnr_T mincol, long lnum_amount, long col_amount));
  1243.   void copy_jumplist __ARGS((win_T *from, win_T *to));
  1244.   void free_jumplist __ARGS((win_T *wp));
  1245.   void set_last_cursor __ARGS((win_T *win));
  1246. *** ../vim-6.2.326/src/proto/ops.pro    Sun Jun  1 12:26:17 2003
  1247. --- src/proto/ops.pro    Thu Mar  4 22:51:23 2004
  1248. ***************
  1249. *** 31,38 ****
  1250.   void ex_display __ARGS((exarg_T *eap));
  1251.   void do_do_join __ARGS((long count, int insert_space));
  1252.   int do_join __ARGS((int insert_space));
  1253. ! void op_format __ARGS((oparg_T *oap));
  1254.   void format_lines __ARGS((linenr_T line_count));
  1255.   int do_addsub __ARGS((int command, linenr_T Prenum1));
  1256.   int read_viminfo_register __ARGS((vir_T *virp, int force));
  1257.   void write_viminfo_registers __ARGS((FILE *fp));
  1258. --- 31,39 ----
  1259.   void ex_display __ARGS((exarg_T *eap));
  1260.   void do_do_join __ARGS((long count, int insert_space));
  1261.   int do_join __ARGS((int insert_space));
  1262. ! void op_format __ARGS((oparg_T *oap, int keep_cursor));
  1263.   void format_lines __ARGS((linenr_T line_count));
  1264. + int paragraph_start __ARGS((linenr_T lnum));
  1265.   int do_addsub __ARGS((int command, linenr_T Prenum1));
  1266.   int read_viminfo_register __ARGS((vir_T *virp, int force));
  1267.   void write_viminfo_registers __ARGS((FILE *fp));
  1268. *** ../vim-6.2.326/src/structs.h    Mon Mar  1 17:11:04 2004
  1269. --- src/structs.h    Thu Mar  4 13:44:30 2004
  1270. ***************
  1271. *** 32,37 ****
  1272. --- 32,43 ----
  1273.   #endif
  1274.   } pos_T;
  1275.   
  1276. + #ifdef FEAT_VIRTUALEDIT
  1277. + # define INIT_POS_T {0, 0, 0}
  1278. + #else
  1279. + # define INIT_POS_T {0, 0}
  1280. + #endif
  1281.   /*
  1282.    * Same, but without coladd.
  1283.    */
  1284. *** ../vim-6.2.326/src/vim.h    Mon Mar  1 17:11:04 2004
  1285. --- src/vim.h    Thu Mar  4 22:50:17 2004
  1286. ***************
  1287. *** 848,853 ****
  1288. --- 848,854 ----
  1289.   #define OPENLINE_DELSPACES  1    /* delete spaces after cursor */
  1290.   #define OPENLINE_DO_COM        2    /* format comments */
  1291.   #define OPENLINE_KEEPTRAIL  4    /* keep trailing spaces */
  1292. + #define OPENLINE_MARKFIX    8    /* fix mark positions */
  1293.   
  1294.   /*
  1295.    * There are four history tables:
  1296. ***************
  1297. *** 1118,1123 ****
  1298. --- 1119,1125 ----
  1299.   #define OP_FOLDCLOSEREC    23    /* "zC" close folds recursively */
  1300.   #define OP_FOLDDEL    24    /* "zd" delete folds */
  1301.   #define OP_FOLDDELREC    25    /* "zD" delete folds recursively */
  1302. + #define OP_FORMAT2    26    /* "gw" format operator, keeps cursor pos */
  1303.   
  1304.   /*
  1305.    * Motion types, used for operators and for yank/delete registers.
  1306. *** ../vim-6.2.326/src/version.c    Sun Mar  7 19:33:55 2004
  1307. --- src/version.c    Mon Mar  8 12:12:35 2004
  1308. ***************
  1309. *** 639,640 ****
  1310. --- 639,642 ----
  1311.   {   /* Add new patch number below this line */
  1312. + /**/
  1313. +     327,
  1314.   /**/
  1315.  
  1316. -- 
  1317. A fool must search for a greater fool to find admiration.
  1318.  
  1319.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  1320. ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  1321. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  1322.  \\\  Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
  1323.