4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: ":s/pat/\=col('.')" always replaces with "1".
12 Solution: Set the cursor to the start of the match before substituting.
17 *** ../vim-6.2.146/src/ex_cmds.c Sat Sep 27 19:36:46 2003
18 --- src/ex_cmds.c Fri Nov 7 16:12:26 2003
24 ! /* Move the cursor to the start of the line, to avoid that it
25 ! * is beyond the end of the line after the substitution. */
26 ! curwin->w_cursor.col = 0;
29 * 3. substitute the string.
34 ! /* Move the cursor to the start of the match, so that we can
35 ! * use "\=col("."). */
36 ! curwin->w_cursor.col = regmatch.startpos[0].col;
39 * 3. substitute the string.
43 sub, new_end, TRUE, p_magic, TRUE);
47 + /* Move the cursor to the start of the line, to avoid that it
48 + * is beyond the end of the line after the substitution. */
49 + curwin->w_cursor.col = 0;
51 /* For a multi-line match, make a copy of the last matched
52 * line and continue in that one. */
53 *** ../vim-6.2.146/src/version.c Sun Nov 9 20:20:26 2003
54 --- src/version.c Sun Nov 9 20:22:20 2003
58 { /* Add new patch number below this line */
64 I once paid $12 to peer at the box that held King Tutankhamen's little
65 bandage-covered midget corpse at the De Young Museum in San Francisco. I
66 remember thinking how pleased he'd be about the way things turned out in his
68 (Scott Adams - The Dilbert principle)
70 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
71 /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
72 \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
73 \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///