Duplicate of A way to access Library examples? - #3 by pfeerick
As of now there doesn’t seem to be simple 1-click button to do this, so copy-pasting the example code a file of the same in the src/
folder is the current way to do it. You can file a feature-request in GitHub - platformio/platformio-core: A professional collaborative platform for embedded development though.