From: NilsOla Nilsson Subject: Re: ksh vi mode: stop 'P' command from moving the cursor To: Ingo Schwarze Cc: Walter Alejandro Iglesias , Anton Lindqvist , millert@openbsd.org, tech@openbsd.org Date: Thu, 24 Apr 2025 18:32:49 +0200 On Thu, Apr 24, 2025 at 05:39:56PM +0200, Ingo Schwarze wrote: > Hello Walter, > > we have now three options what to do with 'P' in ksh(1) VI mode; one > of them also changes the behaviour of 'p'. So i'm asking people: > which one of the three do you prefer? > > If people prefer one of the two solutions proposed by Walter, i'll > polish, test, and commit that. Otherwise, i'll commit the diff i > posted earlier. Something needs to be committed because right now, > the 'P' command misbehaves with UTF-8. > > Walter Alejandro Iglesias wrote on Thu, Apr 24, 2025 at 10:49:02AM +0200: > > On Mon, Apr 21, 2025 at 11:38:01PM +0200, Ingo Schwarze wrote: > > >> here is a patch to change the behaviour of the "paste before" (P) command > >> in the VI command line editing mode of ksh(1). > > > With your diff, after pasting with the 'P' command the cursor lands one > > character *after* the last character in the string pasted. > > Correct. > That is also the character the cursor is on before pasting. > > > I'm not saying this is wrong, maybe it's more convenient, but it's not > > what the 'p' command does > > Correct. > In our ksh(1), 'p' puts the cursor on the last character inserted. One aspect of this is what happens if you paste several times without moving the cursur in between. Tested like this: - started with "=======" - have "abcde" in the paste buffer - position the cursor somewhere in the "======="-string - paste five times The result is for nvi(in ports) and vi pasting with p (messing it up) ====aaaaabcdebcdebcdebcdebcde=== for nvi(in ports) and vi pasting with P (as expected) ====abcdeabcdeabcdeabcdeabcde=== for vim, nvim and bash pasting with p (as expected) ====abcdeabcdeabcdeabcdeabcde=== for vim, nvim and bash pasting with P (messing it up) ====abcdabcdabcdabcdabcdeeeee=== for ksh, kakuone and helix pasting with either p or P (as expected) ====abcdeabcdeabcdeabcdeabcde=== No strong opinion about anything, but this could be seen as a flaw (or two different flaws) in vi and vim, that can not be corrected any more, but is fixed in ksh, kakuone and helix. -- Nils Ola Nilsson, 🐞 nilsola@abc.se, 🦗 +46-70-862 26 96