To answer the question, the following will run an autocommand on :enew:
autocmd BufCreate * if '' == expand("<afile>") | set paste | endif
You can replace BufCreate with BufAdd or BufNew, it will work all the same. The important part is the if '' == expand("<afile>") that will only execute the command if it the new buffer has no name.
NB:
For the specific use-case of pasting text in new buffer, auto-switching to paste mode is not a great solution though, I wouldn't recommend using this.
As the paste is maintained even when you switch buffer. You'd need additional autocommands to unset the paste mode when you switch buffer/window (autocmd WinEnter * set nopaste will work for windows, but for some reason autocmd BufEnter * set nopaste doesn't help when switching buffer).
To ease pasting stuff in new buffers (or otherwise), I'd recommend either:
- typing
"*p or "+p in normal mode, as to use vim's native mechanism to paste from the clipboard registers, as suggested by @dartNNN (assuming you're on your local machine) - using one of the plugins recommended in @peter-rincker's answer
BufCreateinstead ofBufNewfileit should be triggered each time you load a file which isn't listed.BufCreatewill also set paste mode when I open existing files."*pdoes seem to do the trick. It doesn't really solve the issue of executing an autocommand on:enew, but it does help with my specific use-case, thanks.BufCreatedisn't a good solution then.