The new editor.formatOnPaste setting in vscode 1.9 works when pasting with ctrl-v with not in vim mode's p, which should use that setting too to automatically format when pasting.
The formatOnPaste feature listens to browser's paste event however our p is not a real paste. That's why Code's native formatOnPaste doesn't kick in.
A proper solution is
editor.formatOnPaste when running pp's pasted content.It's like re-implementing formatOnPaste again in Vim. Since I did that in Code, I'd like to leave this to anyone who wants to contribute :)
@rebornix can't you just copy your implementation into VSCodeVim :wink:
@johnfn yeah of course. The only thing I'm not sure about is whether users (majority) want to have this feature in Vim.
That's a very good point actually. It's good to focus on issues with the most thumbs up.
Is there a workaround for this?
A proper solution is
Checkeditor.formatOnPastewhen runningp
If it's true, run format selection onp's pasted content.
Set correct final selection.
I'll mention that I prototyped this at one point and it wasn't a great experience. What we really want is VSCode to expose its formatOnPaste implementation, since then from our side it would be atomic. Still, a sort of ugly solution is better than none.
Most helpful comment
The
formatOnPastefeature listens to browser'spasteevent however ourpis not a real paste. That's why Code's nativeformatOnPastedoesn't kick in.A proper solution is
editor.formatOnPastewhen runningpp's pasted content.It's like re-implementing
formatOnPasteagain in Vim. Since I did that in Code, I'd like to leave this to anyone who wants to contribute :)