diff options
author | Christian Brabandt <cb@256bit.org> | 2021-05-30 22:17:25 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-05-30 22:17:25 +0200 |
commit | 2fa9384ca1b600b934bec81a72c5fb7ce757503a (patch) | |
tree | 5bb926693906fc0598364604d50d9bb4daaebe09 /src/register.c | |
parent | d2ea7cf10a4d026ebd402594d656af7d5c811c24 (diff) | |
download | vim-git-2fa9384ca1b600b934bec81a72c5fb7ce757503a.tar.gz |
patch 8.2.2914: cannot paste a block without adding paddingv8.2.2914
Problem: Cannot paste a block without adding padding.
Solution: Add "zp" and "zP" which paste without adding padding. (Christian
Brabandt, closes #8289)
Diffstat (limited to 'src/register.c')
-rw-r--r-- | src/register.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/register.c b/src/register.c index 6ba4e896d..f4d934393 100644 --- a/src/register.c +++ b/src/register.c @@ -1497,6 +1497,7 @@ copy_yank_reg(yankreg_T *reg) * "flags": PUT_FIXINDENT make indent look nice * PUT_CURSEND leave cursor after end of new text * PUT_LINE force linewise put (":put") + * PUT_BLOCK_INNER in block mode, do not add trailing spaces */ void do_put( @@ -1794,7 +1795,7 @@ do_put( bd.textcol = 0; for (i = 0; i < y_size; ++i) { - int spaces; + int spaces = 0; char shortline; bd.startspaces = 0; @@ -1845,12 +1846,16 @@ do_put( yanklen = (int)STRLEN(y_array[i]); - // calculate number of spaces required to fill right side of block - spaces = y_width + 1; - for (j = 0; j < yanklen; j++) - spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0); - if (spaces < 0) - spaces = 0; + if ((flags & PUT_BLOCK_INNER) == 0) + { + // calculate number of spaces required to fill right side of + // block + spaces = y_width + 1; + for (j = 0; j < yanklen; j++) + spaces -= lbr_chartabsize(NULL, &y_array[i][j], 0); + if (spaces < 0) + spaces = 0; + } // insert the new text totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces; |