Bram, when using visual block_mode and replacing the selected block with <Enter>, Vim currently does not break the line, but inserts the linebreak literally, e.g. when doing this:
10o12345<ESC>9k02l<C-V>9jr<CR> you are left with: 12^M45 12^M45 12^M45 12^M45 12^M45 12^M45 12^M45 12^M45 12^M45 12^M45 instead of 12 45 12 45 [...] Attached patch fixes this and adds a test. Best, Christian -- Man wird mit weniger Anstoß über Glaubenssachen spotten als streiten, weil man im ersteren Falle doch noch daran zu glauben scheint. -- Jean Paul -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
diff --git a/src/ops.c b/src/ops.c --- a/src/ops.c +++ b/src/ops.c @@ -2084,6 +2084,7 @@ char_u *newp, *oldp; size_t oldlen; struct block_def bd; + char_u *after_p = NULL; if ((curbuf->b_ml.ml_flags & ML_EMPTY ) || oap->empty) return OK; /* nothing to do */ @@ -2174,25 +2175,40 @@ /* insert pre-spaces */ copy_spaces(newp + bd.textcol, (size_t)bd.startspaces); /* insert replacement chars CHECK FOR ALLOCATED SPACE */ + if (c != '\n' && c != '\r') + { #ifdef FEAT_MBYTE - if (has_mbyte) - { - n = (int)STRLEN(newp); - while (--num_chars >= 0) - n += (*mb_char2bytes)(c, newp + n); + if (has_mbyte) + { + n = (int)STRLEN(newp); + while (--num_chars >= 0) + n += (*mb_char2bytes)(c, newp + n); + } + else +#endif + copy_chars(newp + STRLEN(newp), (size_t)numc, c); + if (!bd.is_short) + { + /* insert post-spaces */ + copy_spaces(newp + STRLEN(newp), (size_t)bd.endspaces); + /* copy the part after the changed part */ + STRMOVE(newp + STRLEN(newp), oldp); + } } else -#endif - copy_chars(newp + STRLEN(newp), (size_t)numc, c); - if (!bd.is_short) { - /* insert post-spaces */ - copy_spaces(newp + STRLEN(newp), (size_t)bd.endspaces); - /* copy the part after the changed part */ - STRMOVE(newp + STRLEN(newp), oldp); + after_p = alloc_check((unsigned)oldlen + 1 + n - STRLEN(newp)); + STRMOVE(after_p, oldp); } /* replace the line */ ml_replace(curwin->w_cursor.lnum, newp, FALSE); + if (after_p != NULL) + { + ml_append(curwin->w_cursor.lnum++, after_p, 0, FALSE); + appended_lines_mark(curwin->w_cursor.lnum, 1L); + oap->end.lnum++; + vim_free(after_p); + } } } else diff --git a/src/testdir/test39.in b/src/testdir/test39.in --- a/src/testdir/test39.in +++ b/src/testdir/test39.in @@ -32,6 +32,8 @@ doh dutVkUj :" Uppercase part of two lines ddppi333k0i222fyllvjfuUk +:" visual replace using Enter +G10o123456789019k05l9jr :/^the/,$w >> test.out :qa! ENDTEST diff --git a/src/testdir/test39.ok b/src/testdir/test39.ok --- a/src/testdir/test39.ok +++ b/src/testdir/test39.ok @@ -11,3 +11,23 @@ DOH DUT 222the yoUTUSSEUU END 333THE YOUTUßeuu end +12345 +78901 +12345 +78901 +12345 +78901 +12345 +78901 +12345 +78901 +12345 +78901 +12345 +78901 +12345 +78901 +12345 +78901 +12345 +78901