@@ -9084,6 +9084,34 @@ nv_edit(cmdarg_T *cap)
90849084 /* drop the pasted text */
90859085 bracketed_paste (PASTE_INSERT , TRUE, NULL );
90869086 }
9087+ else if (cap -> cmdchar == K_PS && VIsual_active )
9088+ {
9089+ pos_T old_pos = curwin -> w_cursor ;
9090+ pos_T old_visual = VIsual ;
9091+
9092+ /* In Visual mode the selected text is deleted. */
9093+ if (VIsual_mode == 'V' || curwin -> w_cursor .lnum != VIsual .lnum )
9094+ {
9095+ shift_delete_registers ();
9096+ cap -> oap -> regname = '1' ;
9097+ }
9098+ else
9099+ cap -> oap -> regname = '-' ;
9100+ cap -> cmdchar = 'd' ;
9101+ cap -> nchar = NUL ;
9102+ nv_operator (cap );
9103+ do_pending_operator (cap , 0 , FALSE);
9104+ cap -> cmdchar = K_PS ;
9105+
9106+ /* When the last char in the line was deleted then append. Detect this
9107+ * by checking if the cursor moved to before the Visual area. */
9108+ if (* ml_get_cursor () != NUL && lt (curwin -> w_cursor , old_pos )
9109+ && lt (curwin -> w_cursor , old_visual ))
9110+ inc_cursor ();
9111+
9112+ /* Insert to replace the deleted text with the pasted text. */
9113+ invoke_edit (cap , FALSE, cap -> cmdchar , FALSE);
9114+ }
90879115 else if (!checkclearopq (cap -> oap ))
90889116 {
90899117 switch (cap -> cmdchar )
@@ -9113,8 +9141,9 @@ nv_edit(cmdarg_T *cap)
91139141 beginline (BL_WHITE |BL_FIX );
91149142 break ;
91159143
9116- case K_PS : /* Bracketed paste works like "a"ppend, unless the
9117- cursor is in the first column, then it inserts. */
9144+ case K_PS :
9145+ /* Bracketed paste works like "a"ppend, unless the cursor is in
9146+ * the first column, then it inserts. */
91189147 if (curwin -> w_cursor .col == 0 )
91199148 break ;
91209149 /*FALLTHROUGH*/
0 commit comments