Patch 8.2.2914
Problem:    Cannot paste a block without adding padding.
Solution:   Add "zp" and "zP" which paste without adding padding. (Christian
            Brabandt, closes #8289)
Files:      runtime/doc/change.txt, runtime/doc/index.txt, src/normal.c,
            src/register.c, src/vim.h, src/testdir/test_normal.vim,
            src/testdir/test_visual.vim


*** ../vim-8.2.2913/runtime/doc/change.txt      2021-01-31 17:02:06.246490203 
+0100
--- runtime/doc/change.txt      2021-05-30 22:10:25.280442415 +0200
***************
*** 1118,1123 ****
--- 1126,1136 ----
                        Using the mouse only works when 'mouse' contains 'n'
                        or 'a'.
  
+ ["x]zp                    or                                  *zp* *zP*
+ ["x]zP                        Like "p" and "P", except without adding 
trailing spaces
+                       when pasting a block.  Thus the inserted text will not
+                       always be a rectangle.
+ 
  You can use these commands to copy text from one place to another.  Do this
  by first getting the text into a register with a yank, delete or change
  command, then inserting the register contents with a put command.  You can
***************
*** 1157,1162 ****
--- 1170,1178 ----
  each of the selected lines (thus replacing the blockwise selected region by a
  block of the pasted line).
  
+ Use |zP|/|zp| to paste a blockwise yanked register without appending trailing
+ spaces.
+ 
                                                        *blockwise-register*
  If you use a blockwise Visual mode command to get the text into the register,
  the block of text will be inserted before ("P") or after ("p") the cursor
*** ../vim-8.2.2913/runtime/doc/index.txt       2021-04-24 14:15:03.680264471 
+0200
--- runtime/doc/index.txt       2021-05-30 22:05:44.389053296 +0200
***************
*** 864,869 ****
--- 864,871 ----
  |zm|          zm                 subtract one from 'foldlevel'
  |zn|          zn                 reset 'foldenable'
  |zo|          zo                 open fold
+ |zp|          zp                 paste in block-mode without trailing spaces
+ |zP|          zP                 paste in block-mode without trailing spaces
  |zr|          zr                 add one to 'foldlevel'
  |zs|          zs                 when 'wrap' off scroll horizontally to
                                   position the cursor at the start (left
*** ../vim-8.2.2913/src/normal.c        2021-05-29 19:17:57.716280905 +0200
--- src/normal.c        2021-05-30 22:05:44.389053296 +0200
***************
*** 2973,2978 ****
--- 2973,2982 ----
                }
                break;
  
+               // "zp", "zP" in block mode put without addind trailing spaces
+     case 'P':
+     case 'p':  nv_put(cap);
+              break;
  #ifdef FEAT_FOLDING
                // "zF": create fold command
                // "zf": create fold operator
***************
*** 7418,7428 ****
        }
        else
            dir = (cap->cmdchar == 'P'
!                                || (cap->cmdchar == 'g' && cap->nchar == 'P'))
!                                                        ? BACKWARD : FORWARD;
        prep_redo_cmd(cap);
        if (cap->cmdchar == 'g')
            flags |= PUT_CURSEND;
  
        if (VIsual_active)
        {
--- 7422,7434 ----
        }
        else
            dir = (cap->cmdchar == 'P'
!                   || ((cap->cmdchar == 'g' || cap->cmdchar == 'z')
!                       && cap->nchar == 'P')) ? BACKWARD : FORWARD;
        prep_redo_cmd(cap);
        if (cap->cmdchar == 'g')
            flags |= PUT_CURSEND;
+       else if (cap->cmdchar == 'z')
+           flags |= PUT_BLOCK_INNER;
  
        if (VIsual_active)
        {
*** ../vim-8.2.2913/src/register.c      2021-03-02 19:04:08.029594922 +0100
--- src/register.c      2021-05-30 22:12:05.324212117 +0200
***************
*** 1497,1502 ****
--- 1497,1503 ----
   * "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,1800 ****
        bd.textcol = 0;
        for (i = 0; i < y_size; ++i)
        {
!           int spaces;
            char shortline;
  
            bd.startspaces = 0;
--- 1795,1801 ----
        bd.textcol = 0;
        for (i = 0; i < y_size; ++i)
        {
!           int spaces = 0;
            char shortline;
  
            bd.startspaces = 0;
***************
*** 1845,1856 ****
  
            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;
  
            // insert the new text
            totlen = count * (yanklen + spaces) + bd.startspaces + bd.endspaces;
--- 1846,1861 ----
  
            yanklen = (int)STRLEN(y_array[i]);
  
!           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;
*** ../vim-8.2.2913/src/vim.h   2021-05-30 14:02:02.279526678 +0200
--- src/vim.h   2021-05-30 22:05:44.389053296 +0200
***************
*** 1068,1073 ****
--- 1068,1074 ----
  #define PUT_LINE      8       // put register as lines
  #define PUT_LINE_SPLIT        16      // split line for linewise register
  #define PUT_LINE_FORWARD 32   // put linewise register below Visual sel.
+ #define PUT_BLOCK_INNER 64      // in block mode, do not add trailing spaces
  
  // flags for set_indent()
  #define SIN_CHANGED   1       // call changed_bytes() when line changed
*** ../vim-8.2.2913/src/testdir/test_normal.vim 2021-05-29 19:17:57.716280905 
+0200
--- src/testdir/test_normal.vim 2021-05-30 22:05:44.389053296 +0200
***************
*** 595,601 ****
  " Test for errors with z command
  func Test_normal_z_error()
    call assert_beeps('normal! z2p')
!   call assert_beeps('normal! zp')
  endfunc
  
  func Test_normal15_z_scroll_vert()
--- 595,601 ----
  " Test for errors with z command
  func Test_normal_z_error()
    call assert_beeps('normal! z2p')
!   call assert_beeps('normal! zq')
  endfunc
  
  func Test_normal15_z_scroll_vert()
*** ../vim-8.2.2913/src/testdir/test_visual.vim 2021-05-29 16:30:08.674611431 
+0200
--- src/testdir/test_visual.vim 2021-05-30 22:05:44.389053296 +0200
***************
*** 1044,1047 ****
--- 1044,1069 ----
    bwipe!
  endfunc
  
+ func Test_visual_put_in_block_using_zp()
+   new
+   " paste using zP
+   call setline(1, ['/path;text', '/path;text', '/path;text', '', 
+     \ '/subdir', 
+     \ '/longsubdir',
+     \ '/longlongsubdir'])
+   exe "normal! 5G\<c-v>2j$y"
+   norm! 1Gf;zP
+   call assert_equal(['/path/subdir;text', '/path/longsubdir;text', 
'/path/longlongsubdir;text'], getline(1, 3))
+   %d
+   " paste using zP
+   call setline(1, ['/path;text', '/path;text', '/path;text', '', 
+     \ '/subdir', 
+     \ '/longsubdir',
+     \ '/longlongsubdir'])
+   exe "normal! 5G\<c-v>2j$y"
+   norm! 1Gf;hzp
+   call assert_equal(['/path/subdir;text', '/path/longsubdir;text', 
'/path/longlongsubdir;text'], getline(1, 3))
+   bwipe!
+ endfunc
+ 
  " vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.2913/src/version.c       2021-05-30 19:29:37.786489673 +0200
--- src/version.c       2021-05-30 22:06:50.280915822 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2914,
  /**/

-- 
Why isn't there mouse-flavored cat food?

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202105302018.14UKI24M1871601%40masaka.moolenaar.net.

Raspunde prin e-mail lui