In powershell.exe you can paste multiple lines using ctrl+v and the shell will give you the lines in an editable fashion, almost as if ` was appended to each line.
Currently Windows Terminal handles pasting with ctrl+v with the same behaviour as pasting using right click in powershell.exe and executes each line separately.
EG:
If you copy and paste using ctrl+v the following block into powershell.exe it gets handled as a single block and you can use arrow keys to move up and change the lines.
$a = "Foo"
$b = "Bar"
Write-Host "$a $b"
to powershell.exe:
PS D:\> $a = "Foo"
>> $b = "Bar"
>> Write-Host "$a $b"
To Windows Terminal:
PS D:\> $a = "Foo"
PS D:\> $b = "Bar"
PS D:\> Write-Host "$a $b"
This comes in handy for me when copying snippets of powershell from other projects or from websites and I need to adjust them slightly without needing to first paste into Notepad, VSCode or ISE to edit.
Perhaps a setting to toggle this kind of pasting behaviour in the profile or a multiline paste command to handle this situation?
It would also make pasting multiple lines more "safe" as you need to hit return to execute the lines.
Bracketed paste mode https://github.com/microsoft/terminal/issues/395 should eventually fix this properly.
You can also remove the Ctrl+V binding in settings.json of Windows Terminal, so that the Ctrl+V is passed to PowerShell, where PSReadLine then pastes the text from the Windows clipboard without executing it. I don't think that can work over SSH, though.
Thanks @KalleOlaviNiemitalo; that pretty much sums it up.
PowerShell outside of Windows Terminal handles pasting on its own, and until #395 lands (plus PSReadline's https://github.com/PowerShell/PSReadLine/issues/579), your best bet is to unbind ^V in your local settings for local clipboard paste (if you only use PowerShell) or rebind PSReadline's Paste to another key.