Yasuhiro Matsumoto wrote:
> if replacing double-byte with single-bute,
> cursor move next.
I see the problem. I notice that the call to del_char() isn't really
necessary, a mch_memmove() is simpler and avoids that the cursor moves.
Hmm, now that I look at this, I see another problem: When using a count for
the "r" command, and replacing a single-byte character with a double-byte
character, the ins_char() will have made the pointer invalid and strange
things might happen.
Try this code instead (around line 4519 in normal.c):
/* Handle three situations:
* 1. replace double-byte with double-byte: set trailbyte.
* 2. replace single-byte with double-byte: insert trailbyte.
* 3. replace double-byte with single-byte: delete char.
if (trailbyte != NUL)
ptr[curwin->w_cursor.col] = trailbyte;
if (n > 1)
/* pointer will have changed, get it again */
ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum,
else if (IsLeadByte(prechar))
mch_memmove(ptr + curwin->w_cursor.col,
ptr + curwin->w_cursor.col + 1,
STRLEN(ptr + curwin->w_cursor.col));
--curwin->w_cursor.col; /* cursor on the last replaced char */
Please check that this works correctly!
hundred-and-one symptoms of being an internet addict:
46. Your wife makes a new rule: "The computer cannot come to bed."
/-/-- Bram Moolenaar --- Bram@...
\-\-- Vim: http://www.vim.org
---- ICCF Holland: http://www.vim.org/iccf